Hi everyone and happy Christmas!
So I was wondering if it is possible to convert the following while-loop into a for-loop:
def bear_room():
print("There is a bear here.")
print("The bear has a bunch of honey.")
print("The fat bear is in front of another door.")
print("How are you going to move the bear?")
bear_moved = False
while True:
choice = input(">")
if choice == "take honey":
dead("The bear looks at you then slaps your face off.")
elif choice == "taunt bear" and not bear_moved:
print("The bear has moved from the door.")
print("You can go through it now")
bear_moved = True
elif choice == "taunt bear" and bear_moved:
dead("The bear gets pissed off and chews your leg off.")
elif choice == "open door" and bear_moved:
gold_room()
else:
print("I got no idea what that means.")
I can think of a way to replace while with a couple of if-elif-elses but doing the exercise of using a for-loop is a riddle to me. I found a thread on reddit where someone suggested to use for+iter() to solve a similar problem. But I can’t really come up with an idea to use this in bear_room(). Do I need to create a list to iterate over which includes the choices from the if-elif-else-part of bear_room()?
I’m greatful for any help with this. Or does it just not make sense to use a for-loop in this case?