After some looking around, this is most likely what I'm looking for, but I can't understand it at all, nor can I figure out how to apply it to my code.
So basically I'm trying to make a basic text based game and I have multiple doors which will say certain things/drop hints for something to come, so I want to give the user a chance to open all of the doors.
Right now if they choose the wrong door they're forced to go back, which is how I want it, but if they choose the right door they're forced to go forward, I'd like to add a "go back" option but I can't figure out how... I'm extremely new to Python so if someone could help me out in extremely simple terms I would really appreciate it, thanks guys, here's my code.
#Def#
def purple_door():'''I'd like it to have the option to type "continue" or "go back"'''
print('"You open the door to find a long dark hall, at the end you can see a glowing white light, perhaps a shiny medal! Oooo shiny medal!')
input('continue')
def red_door():
print('This door opens1')
def orange_door():
print('This door opens2')
def yellow_door():
print('This door opens3')
def green_door():
print('This door opens4')
def blue_door():
print('This door opens5')
def pink_door():
print('This door opens6')
#End Def#
#If or Else#
while True:
door_chosen = input('>')
if door_chosen in ('Purple', 'purple', 'Purple.', 'purple.'):
purple_door()
break
elif door_chosen in ('Red', 'red', 'Red.', 'red.'):
red_door()
elif door_chosen in ('Orange', 'orange', 'Orange.', 'orange.'):
orange_door()
elif door_chosen in('Yellow', 'yellow', 'Yellow.', 'yellow.'):
yellow_door()
elif door_chosen in('Green', 'green', 'Green.', 'green.'):
green_door()
elif door_chosen in ('Blue', 'blue', 'Blue.', 'blue.'):
blue_door()
elif door_chosen in ('Pink', 'pink', 'Pink.', 'pink.'):
pink_door()
else:
print('Please type a color stated above.')
#If or else end#
Any suggestions for improvement are greatly appreciated.
Edit: I guess I didn't explain well enough my apologies.
Yes when any door other than Purple is chosen, it forces you to choose another until you choose purple, this is what I want to happen.
But let's say someone wants to open all the doors and their first guess was purple, now they have to move on, so what I would like to do is give the option to go back, say. ///Example/// "Choose which door you'd like to open"
Purple
"You open the purple door and come to a hall" "Continue, or go back"
Go back
"You decide to go back and look at other doors" ///End///
Then you can choose purple and continue when you're ready. I hope that makes more sense now.