我要将用户的输入放入变量中,我想检查变量是否为用户输入的字母(Y,y,N或n)之一,是否不要求他再次输入字母。即使字母正确(Y,y,N,n),脚本也会进入循环。
我已经尝试过使用“ If”,并且只使用了循环,但还是一样。
仅循环
while while save_to_file != "T" or save_to_file != "t" or save_to_file != "N" or save_to_file != "n":
save_to_file = input("Ask the user to input the letter again... ")
如果在圈中
if save_to_file != "T" or save_to_file != "t" or save_to_file != "N" or save_to_file != "n":
while True:
save_to_file = input("Ask the user to input the letter again... ")
if save_to_file == "T" or save_to_file == "t" or save_to_file == "N" or save_to_file == "n":
break
实际:脚本正在进入循环/如果不需要,则进入循环。 预期:该脚本应跳过循环/ If,然后继续。