What does this means :
>>> a = 12 and 13
>>> a
13
How does and operator works while assigning values or is just that it takes the last value ?
What does this means :
>>> a = 12 and 13
>>> a
13
How does and operator works while assigning values or is just that it takes the last value ?
If the expression on the left of
andis false, it will be returned. Otherwise,andreturns the value on the right:You should think about how this works- check all the combinations of True/False on the left and right, and you'll see that having
andwork this way means the value it returns always reflects the True/False status of both expressions.