我很欣赏我的代码很混乱,但它可以工作,在大多数情况下,它只是无法检测到我何时获胜。我尝试制作Word_chooosed 一根绳子,希望能有所帮助,但没有。
我已经尝试了我的工具包中的所有内容;接下来我可以尝试什么?
输入:
import random
Words = ["Hades".upper(),"Zues".upper(), "pesidon".upper()]
Word_choosed = random.choice(Words)
Word_Choosed = list(Word_choosed)
a =[]
print(Word_Choosed)
for i in Word_choosed:
a += "_"
print(" ".join(a))
wrong = 0
while wrong < 5:
Incorrect = "yes"
Guess = str(input("Guess a letter?\n").upper())
for ltr in range(0, len(Word_choosed)):
if Guess == Word_choosed[ltr]:
a[ltr] = Guess
print(a)
wrong -= 1
Incorrect = "no"
if Guess != Word_choosed:
wrong += 1
if Incorrect == "yes":
print(f"wrong you have {5 - wrong } chances left")
elif wrong == 5:
print("you lost")
elif a == Word_Choosed:
print("you won")
break
输出:
['P', 'E', 'S', 'I', 'D', 'O', 'N']
_ _ _ _ _ _ _
Guess a letter?
p
['P', '_', '_', '_', '_', '_', '_']
Guess a letter?
e
['P', 'E', '_', '_', '_', '_', '_']
Guess a letter?
s
['P', 'E', 'S', '_', '_', '_', '_']
Guess a letter?
i
['P', 'E', 'S', 'I', '_', '_', '_']
Guess a letter?
d
['P', 'E', 'S', 'I', 'D', '_', '_']
Guess a letter?
o
['P', 'E', 'S', 'I', 'D', 'O', '_']
Guess a letter?
n
['P', 'E', 'S', 'I', 'D', 'O', 'N']
Guess a letter?
n
['P', 'E', 'S', 'I', 'D', 'O', 'N']
Guess a letter?
繁星点点滴滴
牛魔王的故事
相关分类