max() function of list in Python

The max() function returns the largest of the elements present in a Python list. The example creates a list of floating point numbers and prints the largest of them.

List Updated 21 Jul 2021 1 min read

Overview

  • The max() function returns the maximum of the elements present in a Python list.

Example

python
# Example Python program that creates

            # list of floating point numbers and

            # prints the largest of them

# List creation

            floats = [1.1, 0.9, 0.6, 1.5, 0.8, 0.2]

print("Floating point numbers from the list:")

            print(floats)

print("The largest floating point number in the list:")

            print(max(floats))

Output

Output
Floating point numbers from the list:

[1.1, 0.9, 0.6, 1.5, 0.8, 0.2]

The largest floating point number in the list:

1.5