I have a bunch of list that contains some name who have access, if the name is true and on the list, then it will print welcome to that name, otherwise, if the user had more than 3 wrongs, then it will print sorry, you're more than 3 times wrong. for that logic, I use this
secret_word = ['Fachry', 'Amri', 'Hasbi']
word = ''
guess = 0
guess_limit = 3
out_of_guesses = False
while word != secret_word and not(out_of_guesses):
if guess < guess_limit:
word = input('What is your real name? ')
guess += 1
else:
out_of_guesses = True
if out_of_guesses:
print("Sorry, you're more than 3 times wrong")
else:
print('Welcome mr ' + secret_word)
but when I input the name, no matter is true or not, it will repeat 3 times and will return "Sorry, you're more than 3 times wrong" even though the name is on the list
Expected results:
if I put one of the names inside the list, it will return welcome (the name itself), as long as the users didn't do 3 more times wrong names
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…