In Python 3.4+, you can use default keyword argument:

>>> max([], default=99)
99

In lower version, you can use or:

>>> max([] or [99])
99

NOTE: The second approach does not work for all iterables. especially for iterator that yield nothing but considered truth value.

>>> max(iter([]) or 0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: max() arg is an empty sequence
Answer from falsetru on Stack Overflow
🌐
Programiz
programiz.com › python-programming › methods › built-in › max
Python max()
default (optional) - default value if the given iterable is empty · max() returns the largest element from an iterable. ... If the items in an iterable are strings, the largest item (ordered alphabetically) is returned. languages = ["Python", "C Programming", "Java", "JavaScript"]
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-max-function
Python - max() function - GeeksforGeeks
July 15, 2025 - This code initializes an empty dictionary, "dictionary," and then uses the max() function with the default argument set to a default value, which is the dictionary {1: "Geek"}.
🌐
ThePythonGuru
thepythonguru.com › python-builtin-functions › max
Python max() function - ThePythonGuru.com
January 7, 2020 - The max() function returns the largest of the input values.Its syntax is as follows:max(iterable[, default=obj, key=func]) -> value PARAMETER …
🌐
Learn By Example
learnbyexample.org › python-max-function
Python max() Function - Learn By Example
April 20, 2020 - # Specify default value '0' L = [] x = max(L, default='0') print(x) # Prints 0
🌐
AskPython
askpython.com › python › built-in-methods › python-max-method
Python max() Function: Find the Largest Value - AskPython
5 days ago - A single positional argument must ... expression works when filtering should happen during iteration, and max() returns its greatest surviving value....
🌐
Real Python
realpython.com › ref › builtin-functions › max
max() | Python’s Built-in Functions – Real Python
With multiple arguments, max() returns the largest of the provided arguments. If default is provided and the iterable is empty, the default value is returned.
Find elsewhere
🌐
Python Examples
pythonexamples.org › python-max-function
max() Builtin Function
a = [] largest = max(a, default = 99) print(f'Largest number in the list is : {largest}.') Largest number in the list is : 99. In this tutorial of Python Examples, we learned the syntax of max() builtin function and how to use it, with the help of examples.
🌐
Hyperskill
hyperskill.org › university › python › max-in-python
Python max() Function — Syntax, key Parameter & Examples
August 10, 2026 - It takes a function that extracts a comparison key from each element. By default, the function compares elements using their natural order, but the key parameter can create custom comparisons. When you pair the max() function with built in functions it can improve its functionality.
🌐
Rip Tutorial
riptutorial.com › default argument to max, min
Python Language Tutorial => Default Argument to max, min
You can't pass an empty sequence ... that will be returned if the sequence is empty, instead of raising an exception: max([], default=42) # Output: 42 max([], default=0) # Output: 0 ·...
🌐
Leapcell
leapcell.io › blog › understanding-python-min-and-max-functions
Understanding Python’s `min()` and `max()` Functions | Leapcell
July 25, 2025 - The default argument handles empty iterables safely. In Python, the min() and max() functions are built-in utilities used to find the smallest and largest items, respectively, in an iterable or among two or more arguments.
🌐
Python
docs.python.org › 3 › builtins › functions.html
Built-in Functions — Python 3.14.8 documentation
The key argument specifies a one-argument ordering function like that used for list.sort(). The default argument specifies an object to return if the provided iterable is empty. If the iterable is empty and default is not provided, a ValueError ...
🌐
Unstop
unstop.com › home › blog › python max() function | all use cases with code examples
Python max() Function | All Use Cases With Code Examples
February 12, 2025 - Here’s the basic syntax when ... by setting len as key argument). default: The (optional)- default value is used when no arguments are provided or an empty iterable is passed....
🌐
Interview Kickstart
interviewkickstart.com › home › blogs › learn › max() function in python: syntax, parameters, and examples
max() Function in Python: Syntax, Parameters & Examples
April 1, 2026 - In the Python function max example below, the largest key is returned based on normal string comparison. ... An empty iterable does not have a largest value, so max([]) raises a ValueError. To handle this safely, use the default parameter.
🌐
Devcuriosity
devcuriosity.com › manual › details › python-max-function
Python - max() function with examples - DevCuriosity
max(iterable_1, ..., key=func, default=obj) returns the largest item from a single iterable or the largest of two or more arguments.
🌐
W3Schools
w3schools.com › PYTHON › ref_func_max.asp
Python max() Function
Python Examples Python Compiler ... Interview Q&A Python Training ... The max() function returns the item with the highest value, or the item with the highest value in an iterable....
🌐
Scaler
scaler.com › home › topics › max() function in python
max() Function in Python- Scaler Topics
June 15, 2022 - For example, tuple, set, list, ... the iterables are performed based on the return value of this key function. default: This optional parameter is returned if the iterable is empty....
🌐
Python Academy
python-academy.org › functions › max
max — Python Function Reference
Python 3.13 · 1 · max(iterable, *[, key, default]) iterable · An iterable object. key · A function to specify a sorting key. default · Default value if the iterable is empty. Examples · Python 3.13 ·