这里试试这个(我尽量少修改代码,这样你就可以自己识别相同的逻辑了)print('Enter correct username and password combo to continue')
count = 0
# "" or '' because you are assigning a value string into it
password = ""
username = ""
# looping will continue when wrong input for three times and ask again...
while password!='Hytu76E' and username!='bank_admin' and count < 3:
# you are collecting user input from CLI separately (you can not assign and operator to such operation as per your code ;)
username = input("Enter username: ")
password = input("Enter password: ")
if password=='Hytu76E' and username=='bank_admin':
# if match, grand and break
print('Access granted')
break
else:
print('Access denied. Try again.')
count+=1 # as per gbse, in the comments, you will need the + to count up
代码中的问题:# you are assigning string value, what for? this would make the loop hit positive the first time
password=Hytu76E # string assignment error in syntax, anyway
username=bank_admin # string assignment error in syntax, anyway
# you can not assigning and operator in the input because of no if condition in this line, also you should compare the values of the input
username=input('Enter username: ') and password=input('Enter password: ')
# if code is ok, then move outside the loop in the case when the user enters the first time good answers
if password=='Hytu76E' and username=='bank_admin':
print('Access granted')
else:
print('Access denied. Try again.')
# you are decremented the counter which would never leave teh loop at 4, you should add one on each iteration so count+=1 (count = count + 1)
count-=1