Python min List Function

Python min List is one of the List functions used to return the minimum value in a list. This section discusses how to use this List minimum function with practical examples. The syntax of the Python list min function is

min(list_name)

Python min List Function Example

The min function returns the minimum value in a List.

IntList = [100, 150, 60, 80, 120, 105]
 
print("The Smallest Element in this List is : ", min(IntList))
The Smallest Element in this List is :  60

It is another Python min function example on an integer list.

int_list = [50, 10, 150, 20, 205, 500, 7, 25, 175]
print("List Items : ", int_list)

# Minimum list element
minimum = min(int_list)

print("\nThe Minimum item in this list = ", minimum)

Minimum or Smallest List Item

List Items :  [50, 10, 150, 20, 205, 500, 7, 25, 175]

The Minimum item in this list =  7

list minimum Example 2

In this example, we declared a string list. Next, we used the min function to return the Minimum value in this list. Here, it uses alphabetical order to find the minimum value in a List.

TIP: Please refer List article and List methods article to understand everything about Python Lists.

Fruits = ['Orange', 'Banana', 'Kiwi', 'Apple', 'Grape', 'Blackberry']
 
print("The Smallest Element in this List is : ", min(Fruits))
The Smallest Element in this List is :  Apple

Python List min Example 3

This python program is the same as the first example. However, this time, we are allowing the user to enter the length of a List. Next, we used For Loop to add numbers to the list.

intList = []

number = int(input("Please enter the Total Number of List Elements: "))
for i in range(1, number + 1):
    value = int(input("Please enter the Value of %d Element : " %i))
    intList.append(value)
 
print("The Smallest Element in this List is : ", min(intList))
Python Min List Function 3

list minimum Example 4

This Python program allows users to enter their own string or words and then find the min string list.

strList = []

number = int(input("Please enter the Total Number of List Elements: "))
for i in range(1, number + 1):
    item = input("Please enter the Value of %d Element : " %i)
    strList.append(item)
 
print("The Smallest Element in this List is : ", min(strList))
Please enter the Total Number of List Elements: 4
Please enter the Value of 1 Element : kiwi
Please enter the Value of 2 Element : grape
Please enter the Value of 3 Element : apple
Please enter the Value of 4 Element : orange
The Smallest Element in this List is :  apple

list min Example 5

Let me use this list min function on Mixed List.

MixedList = ['apple', 'Kiwi', 1, 5, 'Mango']
 
print("The Smallest Element in this List is : ", min(MixedList))

As you can see, it throws an error because it can’t apply < operation on string and int.

Traceback (most recent call last):
  File "/Users/suresh/Desktop/simple.py", line 3, in <module>
    print("The Smallest Element in this List is : ", min(MixedList))
TypeError: '<' not supported between instances of 'int' and 'str'
>>> 

list min Example 6

This time, we used the Nested list (list inside a list). Here, the min function uses the first value in each nested list and returns the least or minimum value.

MixedList = [[1, 2], [2, 3], [4, 5]]
 
print("The Smallest Element in this List is : ", min(MixedList))
The Smallest Element in this List is :  [1, 2]