vendredi 18 novembre 2016

Python, Try and If with Function

I am very new at this, and I am unsure as to why the following code does not work as intended: it does not print in the try, even if the condition is met (user1 in proceed). Help!

def main():
    user1=input("Yes or no? ")
    proceed="Y" or "y"

try:
    main()
    if user1 in proceed:
        print("ok")
except:
    print("out")

Aucun commentaire:

Enregistrer un commentaire