print("\t \t \t What's the password?")
print("\t you have 5 chances to get it right! \n")
secret_word = "green"
guess = ""
guess_count = 0
guess_limit = 5
out_of_guesses = False
hintA = "Ashtons' favorite color"
print("Here is a hint: "+ hintA)
#while loop
while guess != secret_word and not (out_of_guesses):
if guess_count < guess_limit:
guess = input("Enter guess: ")
guess_count += 1
#elif guess_count == 2:
#print("Here is a hint: "+ hintA)
else:
out_of_guesses = True
if out_of_guesses:
print("You have been locked out!")
else:
print("Correct password!")
我不知道如何在2到3次猜测之后添加提示,因为没有它就不可能做到。另外#
中的内容是我的尝试
您可以尝试以下方法:
将输入移到
if...else
语句之外,并更改if...else
语句的位置输出:
相关问题 更多 >
编程相关推荐