Built-ins that take iterables
Many built-ins accept any iterable, so they work on lists, sets, dict keys, and generators alike:
sum(xs),sum(xs, start).min(xs)andmax(xs), withkey=to compare by something else. On an empty input they raiseValueError, unless you passdefault=. Interviewers watch for that empty case.any(xs)is true if at least one item is truthy;all(xs)if every item is. Both stop early. Noteall([])isTrue.sorted(xs)always returns a new list.reversed(xs)returns a lazy iterator and needs a sequence, not a generator.enumerate(xs, start)andzip(a, b)pair things up, also lazily.zip(..., strict=True)raises if the lengths differ.
Knowing these keeps solutions short. max(scores, key=scores.get) finds the
key with the highest value in one line.
Run it, then remove default=None and see the error.