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?''')
  5. print('')
  6.  
  7. def inputCode():
  8. global hasKey
  9. action = input()
  10. if action == 'door':
  11. print('You need to OPEN DOOR to escape this insufferable imprisonment.')
  12. print('')
  13. resetAction()
  14.  
  15. if action == 'key':
  16. if hasKey == True:
  17. print('You are currently holding a KEY, your mind is filled with all the possible uses you could have for such an item! But for now you ponder if it could fit in the DOOR?')
  18. print('')
  19.  
  20. if hasKey == False:
  21. print('With a determined display of digit dexterity you picked up the KEY!')
  22. print('')
  23. hasKey = True
  24. resetAction()
  25.  
  26. if action == 'open door':
  27. if hasKey == False:
  28. print('The DOOR is currently locked, perhaps you can find a KEY?')
  29. print('')
  30. resetAction()
  31.  
  32. if hasKey == True:
  33. print('The DOOR swings open and you make a grand escape, vowing to NEVER be outsmarted by a strong breeze and automatically locking door ever again!')
  34. print('')
  35.  
  36. elif action != 'key' and action != 'door' and action != 'open door':
  37. print('Try to stay focused, you need to OPEN DOOR.')
  38. print('')
  39. resetAction()
  40.  
  41. def resetAction():
  42. action = ''
  43. inputCode()
  44.  
  45.  
  46. playAgain = 'yes'
  47.  
  48. while playAgain == 'yes':
  49. global hasKey
  50. hasKey = False
  51. intro()
  52. inputCode()
  53. playAgain = ''
  54. print('Do you want to play again?')
  55. playAgain = input()
Runtime error #stdin #stdout #stderr 0.05s 63520KB
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 52, in <module>
    inputCode()
  File "prog.py", line 9, in inputCode
    action = input()
EOFError