代码只会让我猜一次。有人可以告诉我我的代码有什么问题吗?
挑战:
编写一个程序,将密码设置为“获得访问权”并要求用户输入密码并不断询问,直到输入正确的密码,然后说“接受”。程序应该计算用户进行了多少次尝试,并在他们被接受后告诉他们。
enter code here
password = 'Gain access'
count = 0
input = input("Enter the password: \n")
while input != password:
print("Incorrect password! Please try again: \n")
count = count + 1
print("You have now got your password wrong " + str(count) + " times. \n")
if(count < 5):
print("Access denied, please contact security to reset your password.")
break
else:
print("Accepted, welcome back.")
print("You had " + str(count) + " attempts until you got your password right.")