を実行した後、私は現在、いくつかの失言(使用して、変数をmispellingより見つける複数のチェック&にもかかわらず、いくつかの奇妙な理由で、「Invent Your Own Computer Games w/ Python」の本、&を始めています「;」 ' : 'が必要です、など)、私のタイプアップdragon.py
はIDLEでの実行を拒否します。エラーメッセージdragon.pyが
さらに悪いことに、エラーメッセージが表示されません。単に"RESTART: /Users/yosemite/Documents/dragon.py"
と表示され、私はプロンプトに戻ります。しかし、このサイトの正式版は、hereが完全に正常に動作しています。
誰でも私がここで間違っていることを知っていますか?更新:ここに私のコードは、ある以前にそれを含めるのを忘れ:
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()
コードを投稿してください。 – FamousJameous
また、明らかに、その本のコードサンプル用の差分ツールがあります。 [このページ](https://inventwithpython.com/diff/?p=dragon)に移動して、コードを入力し、何が違うかを確認してください。 – FamousJameous
ようこそStackOverflowへ。 [再現可能な例](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example)が役に立ちます。 – polka