I'm currently beginning the "Invent Your Own Computer Games w/ Python" book, & for some odd reason, despite multiple checks & finding more than a few gaffes (mispelling a variable, using an ';' when ':' is required, etc.), my type up of dragon.py
refuses to run in IDLE.
Worse, I'm not getting an error message; it simply displays "RESTART: /Users/yosemite/Documents/dragon.py"
and I'm back at the prompt. The official version from the site, found here, however, runs perfectly fine.
Anyone have any idea what I'm doing wrong here? Updated: Here is my code, previously forgot to include it:
import random
import time
def displayIntro():
print ('You are in a land full of dragons. In front of you.')
print ('you see two caves. In one cave, the dragon is friendly.')
print ('and will share his reasure with you. The other dragon')
print ('is greedy and hungry, and will eat you on sight.')
print()
def chooseCave():
cave = ''
while cave != '1' and cave !='2':
print ('Which cave will you go into? ( 1 or 2 )')
cave = input()
return cave
def checkCave(chosenCave):
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)
friendlyCave = random.randint(1, 2)
if chosenCave == str(friendlyCave):
print('Gives you his treasures!')
else:
print('Goobles you up in onebite!')
playAgain = 'yes'
while playAgain =='yes' or playAgain == 'y':
displayIntro()
caveNumber = chooseCave()
checkCave(caveNumber)
print('Do you want to play again? (yes or no)')
playAgain = input()