And Or in Python: int, empty list and empty dictionary
print 2 < 3, 3 < 2 # less-than: return 1 or 0
print 2 or 3, 3 or 2 # return left operand if true
# else return right operand (true or false)
print [] or 3
print [] or {}
print 2 and 3, 3 and 2 # return left operand if false
# else return right operand (true or false)
print [] and {}
print 3 and []
Related examples in the same category