Skip to content
Advertisement

Why does this boolean expression return False?

I expect this

print(False == True and not True)

to output True, but it outputs False instead.

Advertisement

Answer

code run from left. see these lines:

print(False == (True and not True))
# True
>>> False == True
False
>>> not True
False
print(False == True and not True) # -> print(False and False)
# False
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement