This question already has an answer here:
I'd like to be able to use raw_input put in by the user in an if statement, but I have no idea how to do it. Here, I ask them for raw input and if they type, "yes", I want to print, "Your triangle is:". if they type, "no", I want to print "Thank you for your time." Is there a way to do this? Please see my code below:
tri=raw_input("Do the points that you entered form a triangle? (yes or no)")
tri=str(tri)
if tri == "yes" or "Yes" or "YES":
print "Your triangle is an:"
elif tri == "no" or "NO" or "No":
print "Thank you for your time."
else:
print "Not a valid answer, please try again later."
Aucun commentaire:
Enregistrer un commentaire