5. Use any and all for boolean scans

Use any() and all() instead of managing boolean flags by hand.

These builtins move the scan logic into a well-known idiom and keep the loop body out of the way. They short-circuit naturally, so they stop as soon as the answer is known, and they read like the question the code is asking.

5.1. Don’t do this

1has_negative = False
2for value in values:
3    if value < 0:
4        has_negative = True
5        break

5.2. Do this

1has_negative = any(value < 0 for value in values)