min() Minimum value
Last updated: 2026-09-22
min() Minimum value
min() works like max() but returns the smallest item.
| Category | Built-in Functions |
|---|---|
| Kind | Built-in Function |
| Python Version | all |
📝 Syntax
min(iterable, *[, key, default])
min(arg1, arg2, *args[, key])
⚙️ Parameters
| iterable Required | An iterable, or the first compared value in the multi-arg form. |
|---|---|
| args Optional | Additional values to compare (variadic). |
| key Optional | A one-arg function used to derive the comparison key.(Default:None) |
| default Optional | Value returned when the iterable is empty.(Default:None) |
Returns:The smallest item, or default when the iterable is empty.
💥 Raises
ValueError— Raised when the iterable is empty and no default is given.TypeError— Raised when items cannot be compared.
▶ Example
Edit the code, press Run, and see the result in the output panel:
Output:
1
e
🏷️ Related Built-in Functions
💡 Related Cases
More case studies coming soon — check back later.
❓ FAQ
QWhat happens with min([])?
AIt raises a ValueError because an empty sequence has no minimum; pass the default= parameter to get a fallback, e.g. min([], default='empty').
QWhat does min('hello') return?
AIt returns 'e' — strings are compared character by character, and 'e' has the smallest Unicode codepoint among 'hello'.
QAre min() and max() perfectly symmetric in usage?
AYes — the argument forms, key, and default all work identically; the only difference is the direction of comparison.
QHow do I find the element closest to some value?
AUse key with abs: min(lst, key=lambda x: abs(x - target)) — it compares the distance rather than the elements themselves.