Logical Operators
and, or, not — with short-circuit evaluation that returns one of the operands.
Beginner
if sensor and sensor.ready: ... # sensor.ready isn't evaluated if sensor is None
name = user_input or "anonymous" # 'or' returns the first truthy value
not True # False
Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.
Discussion (0)
Sign in or join free to ask questions and discuss this topic.