def life():
print("You wake up")
eat = input("are you hungry? Please Enter y or n.")
if eat.upper() == "Y":
print("I predict you will eat breakfast")
elif eat.upper() == "N":
print("I predict you will skip breakfast")
while eat.upper() not in ("Y","N"):
print("input not accepted")
eat = input("are you hungry? Please Enter y or n.")
if eat.upper() == "Y":
print("I predict you will eat breakfast")
elif eat.upper() == "N":
print("I predict you will skip breakfast")
print("You leave the house")
day = input("is it cloudy? please enter y or n")
if day.upper() == "Y":
print("I predict you will bring an umbrella")
elif day.upper() == "N":
print("I predict you will wear sunglasses")
while day.upper() not in ("Y","N"):
print("input not accepted")
day = input("is it cloudy? please enter y or n")
if day.upper() == "Y":
print("I predict you will bring an umbrella")
elif day.upper() == "N":
print("I predict you will wear sunglasses")
print("You go out for dinner")
food = input("Do you want meat? please enter y or n")
if food.upper() == "Y":
print("I predict you will order steak!")
elif food.upper() == "N":
pass
while food.upper() not in ("Y", "N"):
print("input not accepted")
food = input("Do you want meat? please enter y or n")
if food.upper() == "Y":
print("I predict you will order steak!")
elif food.upper() == "N":
pass
pasta = input("Do you want Pasta: please enter y or n")
if pasta.upper() == "Y":
print("I predict you will order spaghetti and meatballs!!")
elif pasta.upper() == "N":
print("I predict you will order salad.")
while pasta.upper() not in ("Y", "N"):
print("input not accepted")
pasta = input("Do you want Pasta: please enter y or n")
if pasta.upper() == "Y":
print("I predict you will order spaghetti and meatballs!!")
elif pasta.upper() == "N":
print("I predict you will order salad.")
life()
I feel like it is unnecessary to repeat multiple lines of code in the while statement. Is there any way to make the while statement go to a previous line of code and run it from there instead of re-entering the same code back into the while statement. The code seems to run fine but I would like it to be less clunky if possible. Thanks!