I am learning Python 3 currently, and it has gone swimmingly up until now. The goal of this simple dice roller is to accept user input, being Yes/No, and roll said dice. If yes/no is not met, then tell them their answer is invalid and proceed to re-ask question.
Everything works great, except for the fact that I cannot figure out how to accept both "yes" and "y" or "no" and "n" as answers. If I add an or (answery = "yes" or "y") the script will take any answer as a dice roll for some reason. Same goes for making a list, having multiple variables (answery1 = "yes" answery2 = "y"), adding commas (answery = ("yes," "y") ect. Any help would be appreciated.
from random import randint
def reroll():
answer = input("Would you like to roll the die again? Yes/No \n")
answer = answer.lower()
answery = "yes"
answern = "no"
if answer == answery:
print(randint(0, 6))
reroll()
elif answer == answern:
print("Thanks for rolling!")
else:
print("That's not an option.")
reroll()
def roll():
answer = input("Would you like to roll the die? Yes/No \n")
answer = answer.lower()
answery = "yes"
answern = "no"
if answer == answery:
print(randint(0, 6))
reroll()
elif answer == answern:
print("Thanks for rolling!")
else:
print("That's not an option.")
roll()
roll()