将“输入”插入未知位置

2021-09-27 06:12:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我想找出“words”中用户“guess”的位置,然后在正确的位置将猜测的字符与“\”一起打印:

words = "apple"
print("_ " *len(words), end="")

guessed = ""

for char in words:
    guess = input("\n start guessing")

    if guess in words:
        for i in guess:
            guessed += guess
    else:
        print("wrong letter")