Truth and fallback values
Learn in depth →Conditions test truthiness; and/or return operands, while not returns a boolean.
value or fallback; a and b; not valueExample
print(bool([]), bool("0"))
print(0 or 10, "" or "guest")Result
False True 10 guest
Watch for: A fallback using or replaces every falsy value, including zero. Use an explicit None check when zero is valid.
Practise this topic →