簡體   English   中英

回溯(最近調用最后):文件“main.py”,第 12 行,在<module>授權錯誤:TypeError: 'bool' object is not iterable</module>

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

這是我第一次在 python 上自己編碼,我在這方面有錯誤

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")

錯誤在於第二個for loop

for error in authorisation:

您正在嘗試迭代 boolean 變量。

authorisation是一個包含TrueFalse的變量。

object 必須是可迭代的,例如列表:

for item in list:

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM