简体   繁体   中英

Traceback (most recent call last): File "main.py", line 12, in <module> for error in authorisation: TypeError: 'bool' object is not iterable

this is my first time coding on my own on python i am having error in this

invalid = ''
authorisation = False
system_authorisation = (input("hi what is your name? "))
for user in system_authorisation:
  if system_authorisation == "ali":
    authorisation = True
    print ("welcome")
  elif system_authorisation != "ali":
    authorisation = False
  for error in authorisation:
    while authorisation == False:
      invalid = (input("invalid password try again- "))
      if invalid == "ali":
        print("welcome")

The bug lies in the second for loop .

for error in authorisation:

You are trying to iterate over a boolean variable.

authorisation is a variable that contains True or False .

The object must be iterable, like a list for example:

for item in list:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM