![](/img/trans.png)
[英]Traceback (most recent call last): File "main.py", line 11, in <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
是一個包含True
或False
的變量。
object 必須是可迭代的,例如列表:
for item in list:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.