我試圖創建一個簡單的劊子手遊戲,其目標輸出是這樣的: 玩家選擇字母m
輸出:m______
你已經找到字母m
猜測左: 7
輸入猜
但是,我得到的輸出是這樣的: 你已經找到字母m
「_________」(不帶引號)
猜測左圖:7
輸入猜Python的替換字符串
我很奇怪,爲什麼_____未與m________
word = "mystery"
solved = 1
guesses = 7
solver = 0
o = "_______"
while solved == 1:
print(o)
print("Guesses Left:", guesses)
print("Input guess")
guess = str(input())
x = word.find(guess)
if x > -0.5:
print("You have found the letter", guess)
z = o[x:x]
o.replace(_, guess)
solver = solver + 1
if solver == 7:
print("YOU WON!!!!")
solved = 2
else:
guesses = guesses - 1
if guesses == 0:
print("Out of lives...")
solved == 0
由於更換!