Guest User

Untitled

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