Python 3.x Python3-发明你自己的电脑游戏-Dragon.py-无法运行

Python 3.x Python3-发明你自己的电脑游戏-Dragon.py-无法运行,python-3.x,Python 3.x,我正在浏览《用Python发明你自己的电脑游戏》一书。它使用python 3。我使用的是ubuntu的python版本 sayth@sayth-TravelMate-5740G:~$ python3 --version Python 3.2.3 我正在做dragon.py- 这是我的消息来源 import random import time def displayIntro(): print('You are in a land full of dragons. In front

我正在浏览《用Python发明你自己的电脑游戏》一书。它使用python 3。我使用的是ubuntu的python版本

sayth@sayth-TravelMate-5740G:~$ python3 --version
Python 3.2.3
我正在做dragon.py- 这是我的消息来源

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()
不,当我运行程序时,我没有得到任何信息,没有错误或正在运行的程序

sayth@sayth-TravelMate-5740G:~$ python3 dragon2.py 
sayth@sayth-TravelMate-5740G:~$ 
我已经检查了作者的差异工具,我很好。 我用pep8,没问题


如何对此进行故障排除?出了什么问题?显然,没有错误需要修复

您可能需要检查缩进(提示:从
playreach='yes'
开始)。

我是这本书的作者。您还可以使用上的“在线差异工具”查看代码与书中代码之间的任何差异。此比较将显示您的任何打字错误。

是否有方法检查此情况。我本以为会返回一个错误。在更大的项目中,这可能很难找到。