first_item_or(items, default) that returns the first element of list items if the list is non-empty, otherwise returns default. Implement it as a single expression using and/or short-circuit evaluation (not an if/else statement), relying on the fact that Python's and/or return operand values, not just booleans.first_item_or([5, 6, 7], 0)
5
List is non-empty, so its first element is returned.
first_item_or([], 0)
0
Empty list is falsy, so default is returned.
`items and items[0]` evaluates to items[0] only when items is non-empty (truthy).
Chain with `or default` to fall back when the list is empty.