我HVE創建Python的劊子手遊戲,但它似乎沒有工作... 這裏的代碼:劊子手遊戲 - 錯誤while循環
guessed = ''
lives = 7
while lives > 0:
missed = 0
print()
for letter in generated_word:
if letter in guessed:
pritn (letter,end=' ')
else:
print ('_',end=' ')
missed = missed + 1
if missed == 0:
print ('You win!')
quit()
break
guess=input("please guess a letter:")
guessed = guessed + guess
if guess not in generated_word:
print ('\n That letter is not in this word, your lives have been decreased by 1.')
print ('Please try another letter.')
lives = lives - 1
missed = missed + 1
print('your new lives value is')
print(lives)
if lives < 7:
print(''' _______
| | ''')
if lives < 6:
print(' | O ')
if lives < 5:
print(' | | ')
if lives < 4:
print(' | \- -/ ')
if lives < 3:
print(' | | ')
if lives < 2:
print(' | /\\ ')
if lives < 1:
print(' |/ \\ ')
if lives == 0:
print('___|___ ')
print('GAME OVER! You have run out of lives and lost the game')
print('The random word was...')
print(generated_word)
quit()
任何幫助嗎?它說打印沒有定義? 我是新手,有很多錯誤,如果有人能更正此代碼,我將不勝感激。
你使用的是什麼版本的Python?另外,請發佈錯誤的完整文本(如果您有一個堆棧跟蹤)。 – khelwood
打印被定義,pritn不是。 – polku
似乎你已經向generated_word聲明瞭任何值 – Inconnu