我在学校开始学习 Python,作为家庭作业,我们必须制作一个刽子手游戏。我唯一的问题是它似乎总是尝试缩进所有内容,即使我这样做了,它仍然需要缩进。
这是我的代码:
import random
global guess
def checkGuess():
turns = 5
n = 0
guess = input('Please guess a letter:')
guesslen = len(guess)
while len(guess) > n:
if guesslen >1:
print ('Please only guess a single letter.')
checkGuess()
elif guess in secretWord:
print (guess)
n = n+1
checkGuess()
elif guess not in secret:
turns -= 1
print ('Nope.')
print (turns), 'more turns'
if turns < 5: print (' OMMMMMD')
if turns < 5: print (' MMMMMMMMM')
if turns < 5: print (' =MMMMMMMMM?')
if turns < 5: print (' ,MMMMMMMMM:')
if turns < 5: print (' MMMMMMMMM')
if turns < 5: print (' .MMMMM,')
if turns < 5: print (' ')
if turns < 3: print (' ZMMMMMMMMMMMMMMMMM7L')
if turns < 3: print (' MMMMMMMMMMMMMMMMMMMMM')
if turns < 3: print ('MMMMMMMMMMMMMMMMMMMMMMM')
if turns < 3: print ('MMMMMMMMMMMMMMMMMMMMMMM')
if turns < 3: print ('MMMMIMMMMMMMMMMMMMIMMMM')
if turns < 3: print ('MMMM DMMMMMMMMMMMM MMMM')
if turns < 3: print ('MMMM DMMMMMMMMMMMM MMMM')
if turns < 3: print ('MMMM DMMMMMMMMMMMM MMMM')
if turns < 3: print ('MMMM DMMMMMMMMMMMM MMMM')
if turns < 3: print ('MMMM DMMMMMMMMMMMM MMMM')
if turns < 3: print ('MMMM DMMMMMMMMMMMM MMMM')
if turns < 3: print ('MMMM DMMMMMMMMMMMM MMMM')
if turns < 3: print ('MMMM DMMMMMMMMMMMM MMMM')
if turns < 3: print ('MMMM DMMMMMMMMMMMM MMMM')
if turns < 3: print (' ZD DMMMMM?MMMMMM DO')
if turns < 2: print (' DMMMMM MMMMMM')
if turns < 2: print (' DMMMMM MMMMMM')
if turns < 2: print (' DMMMMM MMMMMM')
if turns < 2: print (' DMMMMM MMMMMM')
if turns < 2: print (' DMMMMM MMMMMM')
if turns < 2: print (' DMMMMM MMMMMM')
if turns < 2: print (' DMMMMM MMMMMM')
if turns < 2: print (' DMMMMM MMMMMM')
if turns < 1: print (' DMMMMM MMMMMM')
if turns < 1: print (' DMMMMM MMMMMM')
if turns < 1: print (' DMMMMM MMMMMM')
if turns < 1: print (' DMMMMM MMMMMM')
if turns < 1: print (' DMMMMM MMMMMM')
if turns < 1: print (' MMMM+ ?MMMM')
if turns == 0:
print ('The answer is'), (secretWord)
print('H A N G M A N')
secretWord = random.choice (['crocodile','elephant','penguin','pelican', 'leopard', 'hamster', 'lion',])
i = ('')
g = len(secretWord) <--- THIS IS THE LINE WHERE THE PROBLEM IS
length = 0
print (secretWord)
while g > length:
i = i + (' _')
length = length + 1
print(i)
guess = ('')
checkGuess()
我已经尝试了本网站和其他网站上已经建议的所有方法。任何人都可以帮忙吗?