I cant figure this out in my head.
>>>print("red" == "blue")
False
>>>print("red" == 3 >= 3)
False
so why is the following True?
>>> print("red" == "blue" or 3 >= 3)
True
someone put my brain out of its misery
I cant figure this out in my head.
>>>print("red" == "blue")
False
>>>print("red" == 3 >= 3)
False
so why is the following True?
>>> print("red" == "blue" or 3 >= 3)
True
someone put my brain out of its misery
When you use the Boolean Operator or, only one of the conditions declared has to be true in order for it to return true. 3>=3 is true, so the whole expression is true.
print("red" == "blue" or 3 >= 3)
Analysis:
"red" == "blue" #--> False
3 >= 3 #-->True
Given that there is an OR operator:
"red" == "blue" or 3 >= 3 #--> False OR True --> True
That's because you used or
.
In that specific case, 3 >= 3
returns True, and since it's needs only one True parameter, it returns True, ignoring the other condition.
print("red" == "blue")
#False for obvious reasons as string red is not equal to string blue.
print("red" == 3 >= 3)
this is false as red is not equal to 3
print("red" == "blue" or 3 >= 3)
this is true because 3 == 3