Content · Programming · Python

Python min() Function: Usage and Examples

min() finds the smallest value in an iterable or among several arguments. It works on an iterable and is often clearer than writing a manual accumulation or search loop. See two practical examples, edge cases and.

2 views Published Oct 17, 2026 Updated Oct 18, 2026 Admin

A small report summarizes a collection without creating additional indexing logic.

What You Need to Understand


min() finds the smallest value in an iterable or among several arguments. It works on an iterable and is often clearer than writing a manual accumulation or search loop.

When to Use It


A small report summarizes a collection without creating additional indexing logic.

Step-by-Step Python Example


values = [7, 2, 9]
print(min(values))
print(min(["pear", "fig", "banana"], key=len))

How the Example Works


The smallest integer is 2. The length key selects fig as the shortest word.

Example Output


2
fig
1

A Second Example


Compare this smaller variation with the main example, then experiment with your own values.

values = (value for value in [1, 2, 3])
print(min(values))

Important Behavior and Edge Cases


An empty iterable raises ValueError without a default argument; mixed incomparable types may raise TypeError.

Try It Yourself


Adapt the values and predict the result, then verify it in Python.

Common Beginner Mistakes


  • An empty iterable raises ValueError without a default argument; mixed incomparable types may raise TypeError.
  • Overlooking how an iterable is consumed, how element positions are chosen, or whether a function creates a new list.

Key Takeaways


  • min() finds the smallest value in an iterable or among several arguments.
  • The smallest integer is 2.
  • An empty iterable raises ValueError without a default argument; mixed incomparable types may raise TypeError.
Share this resourceSend this page to someone who may find it useful.