Return the smallest item from one iterable or the smallest of two or more arguments.
Syntax
min(iterable, /, *, key=None) | min(iterable, /, *, default, key=None) | min(arg1, arg2, /, *args, key=None)Parameters
| Name | Description |
|---|---|
iterableString | list | tuple | dict | Single iterable input. Dictionaries compare keys. Depends on overload · Positional only No default |
argsAny | Additional positional values when passing two or more arguments. Depends on overload · Variadic No default |
defaultAny | Value returned when the single iterable is empty. Only valid with one iterable argument. Depends on overload · Keyword only Default: - |
keyCallable? | One-argument callable used to compute comparison keys. Optional · Keyword only Default: None |
Returns
Any — The original smallest item, or default when an empty iterable is provided with default=.Behavior / side effects
Return the smallest item from one iterable or the smallest of two or more arguments. key can compute the value used for ordering; ties keep the first item encountered.
Execution
- Blocking: Conditional
- Thread safety: Use separate objects per flow
- Parallel execution: Conditional
The operation processes values in the calling flow. A key callable also runs there and may perform waits or side effects; no asynchronous execution is implied.
Example
# Pick the lowest score, with a safe empty-list fallback
best = min([0.9, 0.7, 0.85])
fallback = min([], default="none")
closest = min([12, -5, 7], key=lambda value: abs(value))
text(str(closest))Errors / limitations
No additional limitations documented; follow the parameter and behavior contract above.
Related APIs
None