fork download
  1. def intro():
  2. print('''You are in a locked room.
  3. You will need to OPEN DOOR to ecape this terrible trap.
  4. What will you do?\n''')
  5.  
  6.  
  7. def input_code():
  8. has_key = False
  9. is_door_unlocked = False
  10. while not is_door_unlocked:
  11. action = input()
  12. if action == 'door':
  13. print('You need to OPEN DOOR to escape this insufferable imprisonment.\n')
  14. elif action == 'key':
  15. if has_key:
  16. print('You are currently holding a KEY, your mind is filled with all the possible uses you could have '
  17. 'for such an item! But for now you ponder if it could fit in the DOOR?\n')
  18. else:
  19. print('With a determined display of digit dexterity you picked up the KEY!\n')
  20. has_key = True
  21. elif action == 'open door':
  22. if has_key:
  23. print('The DOOR swings open and you make a grand escape, vowing to NEVER be outsmarted '
  24. 'by a strong breeze and automatically locking door ever again!\n')
  25. is_door_unlocked = True
  26. else:
  27. print('The DOOR is currently locked, perhaps you can find a KEY?\n')
  28. else:
  29. print('Try to stay focused, you need to OPEN DOOR.\n')
  30.  
  31.  
  32. if __name__ == '__main__':
  33. while True:
  34. intro()
  35. input_code()
  36. print('Do you want to play again?')
  37. if not input() == "yes":
  38. break
  39.  
Runtime error #stdin #stdout #stderr 0.03s 63544KB
stdin
Standard input is empty
stdout
You are in a locked room.
You will need to OPEN DOOR to ecape this terrible trap.
What will you do?

stderr
Traceback (most recent call last):
  File "prog.py", line 35, in <module>
    input_code()
  File "prog.py", line 11, in input_code
    action = input()
EOFError