samedi 29 septembre 2018

Python - How can I make if statements get the letters before the actual word?

I know the title is really really badly worded, so let me explain with a quick bit of code.

Code:

choice = raw_input("Do you like pineapple? Y/N: ")
if choice == "y".lower() or choice == "ye".lower() or choice == "yes".lower():
    print("Sammmmeee")
else:
    print("Nani! You criminal!")

How could I make it so instead of doing:

if choice == "y".lower() or choice == "ye".lower() or choice == "yes".lower():

it automatically lets you do, "y" "ye" or "yes" without needing to do "or" so much?

Aucun commentaire:

Enregistrer un commentaire