How to use if-statement and elif with [list] in python 3,

Viewed 16

I'm trying to make a quiz game for my kid so I'm using a lot of 'if, elif, else' statements. I want to use multiple choice answers in the list [] but I always get a 'wrong' answer. single variables are working but I can't use a list. the second elif statement ignores the list. Here is an example of one of the questions:

question_1 = "What is the capital city of Canada? "
print(question_1)

while True:
    answer = input('').lower()
    if answer == "toronto":
        print("Close but it's not Toronto. Try again please.")
    elif answer == ['otawa', 'otwa', 'otawo']
        print("You are right but your spelling is a bit wrong. Try again ")
    elif answer == 'ottawa':
        print(correct_ans)
        break
    else:
        print(wrong_ans)

Thank you in advance.

0 Answers
Related