Apr-07-2020, 08:06 PM
From the Python Documentation
In other words, whenever the first item in an and is true, return the second item.
So for your tuples a and b, are they false or true?
Since neither of your tuples are empty, they are both evaluated as true. That means you'll always see the second item returned.
Quote:x and y --- if x is false, then x, else y
In other words, whenever the first item in an and is true, return the second item.
So for your tuples a and b, are they false or true?
Quote:By default, an object is considered true unless its class defines either a __bool__() method that returns False or a __len__() method that returns zero, when called with the object. 1 Here are most of the built-in objects considered false:
- constants defined to be false: None and False.
- zero of any numeric type: 0, 0.0, 0j, Decimal(0), Fraction(0, 1)
- empty sequences and collections: '', (), [], {}, set(), range(0)
Since neither of your tuples are empty, they are both evaluated as true. That means you'll always see the second item returned.
>>> 1 and 2 2 >>> 2 and 1 1