Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am trying to have multiple answers to 1 question. How can I make that happen here?
I want all numbers between 10 and 20 to be correct, while everything else to be wrong:

print ("Say a number between 10 or 20 "
       "Only full numbers")

answer = 0

while answer != "10":

    answer = input()
    if answer == '10':
        print("Right!")
    else:
        print ("Wrong try again!")
question from:https://stackoverflow.com/questions/65601352/python-to-have-multiple-correct-answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
197 views
Welcome To Ask or Share your Answers For Others

1 Answer

Cast to int, then compare:

answer = int(input())
if 10 <= answer <= 20:
    print("Right!")
else:
    print ("Wrong try again!")

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...