samedi 27 janvier 2018

OR operator not working in if block Python [duplicate]

This question already has an answer here:

if text == "Hello" or "Hey":
    print("You typed Hello or Hey")
else
    print("You did not type Hello or Hey")

`When I type in Hello or Hey it says You typed Hello or Hey. However, When I type in foo or coo, it says the same thing: You typed Hello or Hey. When I exclude the or and "Hey", It asks just like the logic says. I am wondering if there is a way to ask if you typed in ONLY Hello or Hey. Python 3.6.4. I am running Mac OSX high Seirra. I have looked all over the Internet all found nothing. If this is a copy, please provide a url to the site.

Aucun commentaire:

Enregistrer un commentaire