【发布时间】:2018-04-22 11:24:56
【问题描述】:
刚开始使用 python 并为此绞尽脑汁,但似乎无法正确解决。
print('Enter correct username and password combo to continue')
count=0
password=Hytu76E
username=bank_admin
while password!='Hytu76E' and username!='bank_admin' and count<4:
username=input('Enter username: ') and password=input('Enter password: ')
if password=='Hytu76E' and username=='bank_admin':
print('Access granted')
else:
print('Access denied. Try again.')
count-=1
语法错误,无法分配给第 6 行 username=input 上的运算符。
【问题讨论】:
-
格式化您的代码。你的 while 条件否定了其中的 if 条件。
-
把
count-=1改成count+=1然后去掉while循环中多余的用户名/密码检查 -
值
password和username不应该在引号内吗?
标签: python loops while-loop