jeudi 13 juillet 2017

How do I get this choose your own adventure story in python to start over if the user enters that they want to play again?

Here is my code so far, which works:

print('Welcome to choose your own adenture.')
print('You enter a room with two doors.  Do you want to enter the red door or the white door?')
door = input()

while True:

  if door == 'white':
    print("there was a dragon behind the door.  It ate you and you died.")
    break
  elif door == 'red':
    run_or_dead = input("there is a bear behind the door.  Do you want to wave your arms and shout, or play dead?")
    while True:
      if run_or_dead == 'wave':
        print("Nice try, but the bear did't buy it.  It ate you and you died.")
        break
      elif run_or_dead == 'play dead':
        print("Nice try, but the bear did't buy it.  It ate you and you died.")
        break
      else:
        run_or_dead = input('Not a valid answer.  Do you want to wave or play dead?')
    break

  else:
    door = input('that is not a valid choice.  Do you want to enter the red door or the white door?')

I can't figure out how to get the program to ask the user if they want to repeat the whole process and do so if they enter 'yes'

Aucun commentaire:

Enregistrer un commentaire