vendredi 29 décembre 2017

How to repeat an operation after If statement ( back to top ) in Python 3

I just recently started writing code and using SO. I'm stuck. I've done a little research on how to repeat a whole operation but nothing seems to work. Any help will be greatly appreciated. I'm trying to loop this code so if there is an error in typing "YES" or "NO" the program will go back to the top and start over for a maximum of 10 times. Then maybe it could print "Overload, please restart".

This is the current code I'm working on:

answer1=input("Are you unhappy-YES OR NO").lower()
if answer1=="yes":
    print("Did you know God loves you?")
    print("God is great and forgiving.")
elif answer1=="no":
    print("Thats because God loves you!")
    print("God is great and forgiving.")
elif answer1=="":
    print("ERROR-Please answer Yes or No")
else:
    print("ERROR-Please answer Yes or No")

Aucun commentaire:

Enregistrer un commentaire