Python 我有一个while循环:whilex==False或y!=10:,但当Y旋转到10时,它将继续运行循环

Python 我有一个while循环:whilex==False或y!=10:,但当Y旋转到10时,它将继续运行循环,python,Python,我有这个代码,但当Y变成10时,它会继续运行循环,为什么? 我是python的初学者,所以请不要认为我很愚蠢或是什么:) 由于使用了或,因此代码仅检查是否满足其中一个条件。因此,只要x==False为true,代码就会运行。如果希望代码在y==10时结束,则应改用和运算符。仅当两个条件均为真时,此操作才会运行代码,并且当其中一个条件变为假时(例如,y==10),代码将不会运行。当x==false和y!=10: def destiny_calculator(): mass = str(in

我有这个代码,但当Y变成10时,它会继续运行循环,为什么? 我是python的初学者,所以请不要认为我很愚蠢或是什么:)


由于使用了
,因此代码仅检查是否满足其中一个条件。因此,只要
x==False
为true,代码就会运行。如果希望代码在
y==10
时结束,则应改用
运算符。仅当两个条件均为真时,此操作才会运行代码,并且当其中一个条件变为假时(例如,
y==10
),代码将不会运行。

当x==false和y!=10:
def destiny_calculator():
    mass = str(input("enter the mass of your material (it could be in gram, milligram, kilogram or ton "))
    if mass.isdigit() == False:
        try:
            float(mass)
        except Exception:
            x = False
            y = 0
            while x == False or y != 10:
                print("Please enter JUST a number")
                mass = str(input("enter the mass of your material (it could be in gram, milligram, kilogram or ton - "))
                y = y + 1
                print (y)
            if y == int(10):
                print("Too many errors")
                exit()
            else:
                pass
        else:
            pass