We use “truthy” and “falsy” to differentiate from the bool values True and False. A “truthy” value will satisfy the check performed by if or while statements. As explained in the documentation, all values are considered “truthy” except for the following, which are “falsy”:
NoneFalse- Numbers that are numerically equal to zero, including:
00.00jdecimal.Decimal(0)fraction.Fraction(0, 1)
- Empty sequences and collections, including:
[]– an emptylist{}– an emptydict()– an emptytupleset()– an emptyset''– an emptystrb''– an emptybytesbytearray(b'')– an emptybytearraymemoryview(b'')– an emptymemoryview- an empty
range, likerange(0)
- objects for which
obj.__bool__()returnsFalseobj.__len__()returns0, given thatobj.__bool__is undefined