有人可以帮我做Hangman游戏吗? (蟒蛇)

时间:2020-05-02 15:30:23

标签: python-3.7

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

enter image description here enter image description here

0 个答案:

没有答案