Min() Function Of List In Python

Overview:

  • The min() function returns the smallest of the elements present in a Python list.

Example:

# Example Python program that constructs
# a Python list of integers and returns the smallest of
# the elements 

# Construct a Python list object
elems = [10, 20, 60, 70, 5, 40, 30]

# Find the smallest of the elements
smallestElement = min(elems)

print("Unordered elements from a Python list:")
print(elems)

print("Smallest of the elements:")
print(smallestElement)

Output:

Unordered elements from a Python list:

[10, 20, 60, 70, 5, 40, 30]

Smallest of the elements:

5

 


Copyright 2023 © pythontic.com