【发布时间】:2018-10-07 08:27:24
【问题描述】:
代码只会让我猜一次。有人可以告诉我我的代码有什么问题吗?
挑战:
编写一个程序,将密码设置为“Gain Access”并询问 用户输入密码并不断询问直到密码正确 输入,然后说“接受”。程序应该计算多少 用户已经尝试并在他们完成后告诉他们 接受。
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.")
【问题讨论】:
-
这是什么语言?
-
Python 是正在使用的语言。
-
在这种情况下还包括控制台的输出。我假设当您最初输入错误密码时,它会非常快地连续输出 5 次“拒绝访问”?