Python min() built-in function

From the Python 3 documentation

Return the smallest item in an iterable or the smallest of two or more arguments.

Introduction

The min() function is the counterpart to max(). It can be used in two ways:

  1. With an iterable (like a list or tuple), it returns the smallest item.
  2. With two or more arguments, it returns the smallest of them.

Examples

Finding the min in an iterable:

numbers = [10, 2, 1, 40, 5]
print(min(numbers))  # Output: 1

letters = ('z', 'b', 'a')
print(min(letters)) # Output: 'a'

Finding the min of several arguments:

print(min(10, 20, 5)) # Output: 5

Subscribe to pythoncheatsheet.org

Join 16,702+ Python developers in a two times a month and bullshit free publication , full of interesting, relevant links.