-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdragon.py
44 lines (34 loc) · 1.09 KB
/
dragon.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import random
import time
def display_intro():
print("""\nYou are in a land full of dragons. In front of you,
you see two caves. In one cave, the dragon is friendly
and will share his treasure with you. The other dragon
is greedy and hungry, and will eat you on sight.""")
print()
def choose_cave():
cave = ''
while cave != '1' and cave != '2':
print("Which cave will you go into? (1 or 2)")
cave = input()
return cave
def check_cave(chosen_cave):
print("You approach the cave...")
time.sleep(2)
print("It is dark and spooky...")
time.sleep(2)
print("A large dragon jumps out in front of you! He opens his jaws and...")
print()
time.sleep(2)
friendly_cave = random.randint(1, 2)
if chosen_cave == str(friendly_cave):
print("Gives you his treasure!")
else:
print("Gobbles you down in one bite!")
playAgain = 'yes'
while playAgain == 'yes' or playAgain == 'y':
display_intro()
caveNumber = choose_cave()
check_cave(caveNumber)
print("\nDo you want to play again? (yes or no)")
playAgain = input()