【发布时间】:2019-12-23 18:54:21
【问题描述】:
我想创建一个刽子手游戏。我希望它继续调用 x 并打印 new_word 直到没有“_”。我已经尝试过了,但插槽不断刷新。它一直在重印。它不会更新值本身。
word = 'EVAPORATE'
wordlist = list(word)
dict = dict(enumerate(wordlist))
slots = list('_' * len(word))
x = input("Guess the letter: ")
def game():
for a,b in dict.items():
if b == x:
slots[a] = x
new_word = ' '.join(slots)
print(new_word)
game()
【问题讨论】:
-
请点击此链接,希望对您有所帮助codereview.stackexchange.com/questions/178312/…
标签: python python-3.x if-statement while-loop return