Default Argument to max min
suggest changeYou can’t pass an empty sequence into max or min:
min([])
ValueError: min() iterable argument is empty
Since Python 3.4, max and min accept the keyword argument default. That value is returned when the sequence is empty, instead of raising an exception:
max([], default=42)
# Output: 42
max([], default=0)
# Output: 0
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents