1
我没有得到这个Python代码所需的结果。需要帮忙。虽然循环测试
当您输入满足条件的字符串时,while循环应该停止。
代码:
x = input("Enter input: ")
while (int(x[3]) != 1 or int(x[3]) != 2):
print("The fourth character must be a 1 or 2")
x = input("Enter input again: ")
看起来''或'应该是'和'。 – Carcigenicate
您输入的任何数字总是不等于1或2,因此条件总是成功。 – alexis