Advertisement
Guest User

Untitled

a guest
May 28th, 2020
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.14 KB | None | 0 0
  1. import random
  2. import time
  3.  
  4. def displayIntro():
  5.     print('''You are in a land full of dragons. In front of you you see two
  6. caves. In one cave, the dragon is friendly and will share his treasure
  7. with you. The other dragon is greedy and hungry, and will eat you on sight.''')
  8.     print()
  9.  
  10. def chooseCave():
  11.     cave = ''
  12.     while cave != '1' and cave != '2':
  13.         print('Which cave will you go into? (1 or 2)')
  14.         cave = input()
  15.  
  16.     return cave
  17.  
  18. def checkCave(chosenCave):
  19.     print('You approach the cave...')
  20.     time.sleep(2)
  21.     print('It is dark and spooky...')
  22.     time.sleep(2)
  23.     print('A large dragon jumps out in front of you! He opens his jaws and ...')
  24.     print()
  25.     time.sleep(2)
  26.  
  27.     friendlyCave = random.randint(1,2)
  28.  
  29.     if chosenCave == str(friendlyCave):
  30.         print('Gives you his treasure!')
  31.     else:
  32.         print('Gobbles you down in one bite!')
  33.  
  34.  
  35. playAgain = 'yes'
  36. while playAgain == 'yes' or playAgain == 'y':
  37.     displayIntro()
  38.     caveNumber = chooseCave()
  39.     checkCave(caveNumber)
  40.  
  41.     print('Do you want to play again? (yes or no)')
  42.     playAgain = input()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement