我想做一个循环,让用户卡住直到输入正确的单词,但是当输入正确的单词时它不会显示正确的输出

I want to make a loop which stucks user till the correct word entered, but when the correct word entered it doesn't show the proper output

我想做一个循环让用户卡住直到输入正确的词,但是当输入正确的词时它不显示正确的输出。这是我所做的

word = "High Sir"
        Letter = input("How is the Josh! \n")
        while Letter!= word:
            if Letter == word:
                Letter = ("Well Done! You are selected for next stage.")
            else:
                Letter = input("Bullshit, Enter Again\n")

它不起作用,因为您的循环条件是 while Letter != word,这意味着您仅在 Letterword 不相等时才进入循环。因此,当用户输入正确的单词时,Letterword 变得相等并且循环条件失败,这就是它不进入循环的原因。你想要这样的东西:

required_word = "High Sir"

while True:
    user_word = input("How is the Josh! \n")
    
    if user_word == required_word :
        print("Well Done! You are selected for next stage.")
        break
    else:
        print("Incorrect word! Try again")