Python3 - Invent Your Own Ocmputer Games - Dragon.py - Fails to Run
I am running through the book invent your own computer games with Python.
Which uses python 3. I am on ubuntu with python version.
sayth@sayth-TravelMate-5740G:~$ python3 --version
Python 3.2.3
I am doing dragon.py - Dragon.py authors source This is my source.
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 treasure 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 in to? (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 and...')
print()
time.sleep(2)
friendlyCave = random.randint(1, 2)
if chosenCave == str(friendlyCave):
print('Gives you his treasure')
else:
print('Gobbles you up in one bite')
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()
No when I run the program I get nothing no errors or working program.
sayth@sayth-TravelMate-5740G:~$ python3 dragon2.py
sayth@sayth-TravelMate-5740G:~$
I have checked the authors diff tool diff tool and I am good. I use pep8
and its ok.
How do you troubleshoot this? What is wrong there are no errors to fix,
apparently.
No comments:
Post a Comment