Bradley Kirton's Blog

Published on Aug. 10, 2023

Go home

Avoiding ValueError: max() arg is an empty sequence

Today I learned that the max and min functions in python take an optional default argument which if provided is returned in the event the provided iterable is empty.

max([], default=None)
min([], default=None)