This question already has an answer here:
- “or” conditional in Python troubles 3 answers
- How do I test multiple variables against a value? 14 answers
I'm just writing a simple if statement. The second line only evaluates to true if the user types "Good!" If "Great!" is typed it'll execute the else statement. Can I not use or like this? Do I need logical or?
weather = input("How's the weather? ")
if weather == "Good!" or "Great!":
print("Glad to hear!")
else:
print("That's too bad!")
Aucun commentaire:
Enregistrer un commentaire