While posting this question, I've already checked the other links that have similar titles. All of those either don't have an answer to my question, or don't apply to this piece of code. For example, the link here: Why is my batch script running both if and else statement when if statement matches? says that it's because the OP used echo in the script. Here, I don't use it but I still get the result of both the if and the else.
while True:
selection = input("Type a command or use a page selection")
if selection in ('exit','quit'):
sys.exit()
if selection in ('page 1','1'):
print("Page 1 text here")
if selection in ('page 2','2'):
print("Page 2 text here")
else:
print("Invalid command or page number")
Aucun commentaire:
Enregistrer un commentaire