def getResult(status): 如果(状态==单词): 结果=“您赢了” 返回结果 其他: 结果=“您输了” 返回结果 def updateStatus(word,x,status):
if(word.count(x) == 0):
new_status = status
return new_status
elif (word.count(x) > 0):
find_index = word.find(x)
indexes = []
while find_index != -1:
indexes.append(find_index)
find_index = word.find(x, find_index + 1)
for i in range(len(indexes)):
status = status[:indexes[i]] + x + status[indexes[i] + 1:]
new_status = status
return new_status
def startGame(word): 状态=“” new_status =“”
count = len(word)
for i in range(count):
status = status + "_"
while count > 0:
x = input("%s chances, Enter a letter :" % count)
updateStatus(word, x, status)
count = count - 1
print(updateStatus(word, x, status))
if (count == 0) or (status == word):
return getResult(status)
我想制作_____-> H____-> HE___-> HELL_, 但是结果是_____-> H____-> _____...
您能找到问题所在吗? enter image description here