Try this :
print("whats the number?")
required_number = [8,9]
while True:
number = int(input())
if number in required_number :
print('GOT IT')
break
else:
print('Wrong number try again')
Sample output in shell :
whats the number?
5
Wrong number try again
2
Wrong number try again
4
Wrong number try again
8
GOT IT
manpreet
Best Answer
2 years ago
I am making a text based adventure game in python 3 and I was wondering what the simplest loop is. Using the code I have, it continues to print
"whats the number"
even when you put the correct number, also giving9
as input doesnt work. It also doesn't work when I give("8","9")
. Here is my code :