I come from C background and found this quite strange.
a = 0
b = 0
if (a == b) != 0:
print('non zero and equal')
else:
print('something wrong')
This prints "non zero and equal".
In C, a == b
evaluates to true
, i.e. non-zero.
Now, you compare non-zero with zero and this comes to false
, i.e. 0.
How does this work in Python?
I tried doing something like this:
if a==b !=0:
It worked but I got to know there is some lazy evaluation there and I need to understand it.