Friday, 19 August 2016

My python code has errors, but just in the try- except loop.

My python code has some errors in the try- except loop. If you enter an input which is not yes or no, it first prints the "yes" reply output, then once you answer the question it shows the output for if you do not enter yes or no. Here's the code:



playAgain = None

while playAgain != "Yes" or "No" or "yes" or "no" or "y" or "n":

try:
playAgain = str(input("Do you want to play again? Enter Yes or No: "))
if playAgain == "Yes" or "y" or "yes":
displayIntro()
elif playAgain == "No" or "no" or "n":
print("Oh, well. The magic 8 ball will see you next time...")
sys.exit()
except:
print("That wasn't yes or no, idiot. The magic 8 ball will not give a fortune to such an imbocile.")



Please help and thank you!

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...