I am learning python right now and there is guessing game within the tutorial. You have to guess a word and you have 3 tries until you fail. Now I want to change the code that the word you have to guess is a part of a list not a single value password = ["123456", "qwerty", "password"]
instead of password = "123456"
I tried changing while userInput != password
to while userInput != password[0-2]
but only the secound item from the list gives me correct then. Can you help me please?
password = ["123456", "qwerty", "password"]
userInput = ""
count = 0
limit = 3
out_of_guesses = False
while userInput != password and not(out_of_guesses):
if count < limit:
userInput = input("Enter guess:")
count = count + 1
else:
out_of_guesses = True
if out_of_guesses:
print("You failed")
else:
print("Correct!")