door = input("Do you want to open the door? Enter yes or no: ").lower()
while door != "yes" and door != "no":
print("Invalid answer.")
door = input("Do you want to open the door? Enter yes or no: ").lower()
if door == "yes":
print("You try to twist open the doorknob but it is locked.")
elif door == "no":
print("You decide not to open the door.")
Is there an easier way to use the while loop for invalid answers? So I won't need to add that line after every single question in the program.
I tried def() and while true, but not quite sure how to use the them correctly.