samedi 21 mars 2015

Python | Is it possible to have multiple outcomes of one IF statement?

Making an IT quiz for school and I don't want it to be case sensitive, so I'd have 2 if statements if I want there to be 2 possible answers. My problem is that only one answer works.. May sound confusing.



a = input("And the answer is...")

if a == "answer1":
print("Correct!")

if a == "answer2":
print("Correct!")

else:
print("Incorrect!")


The outcome if you enter "answer1" is:



Correct!
Incorrect!


However, "answer2" will give you:



Correct!


Basically, I want both "answer1" and "answer2" to have the outcome of "Correct!"


Aucun commentaire:

Enregistrer un commentaire