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. global escaped
  10. while escaped == False:
  11. action = input()
  12. if action == 'door':
  13. print('You need to OPEN DOOR to escape this insufferable imprisonment.')
  14. print('')
  15.  
  16. if action == 'key':
  17. if hasKey == True:
  18. 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?')
  19. print('')
  20.  
  21. if hasKey == False:
  22. print('With a determined display of digit dexterity you picked up the KEY!')
  23. print('')
  24. hasKey = True
  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.  
  31. if hasKey == True:
  32. 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!')
  33. print('')
  34. hasKey = False
  35. escaped = True
  36.  
  37. elif action != 'key' and action != 'door' and action != 'open door':
  38. print('Try to stay focused, you need to OPEN DOOR.')
  39. print('')
  40.  
  41. playAgain = 'yes'
  42.  
  43. while playAgain == 'yes':
  44. global escaped
  45. escaped = False
  46. global hasKey
  47. hasKey = False
  48. intro()
  49. inputCode()
  50. playAgain = ''
  51. print('Do you want to play again?')
  52. playAgain = input()
Runtime error #stdin #stdout #stderr 0.05s 63664KB
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 49, in <module>
    inputCode()
  File "prog.py", line 11, in inputCode
    action = input()
EOFError