Python min List Function

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

min(list_name)

Python min List Function Example 1

The min function returns the minimum value in a List.

# Python List Min Function

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

List min 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 the alphabetical order to find minimum value in a List.

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

# Python List Min Function

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 minimum 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.

# Python List Min Function

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

Python min List Example 4

This program allows users to enter their own string or words and then finds the minimum string

# Python List Min Function

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

Python min List Function Example 5

Let me use this min function on Mixed List.

# Python List Min Function

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

As you can see, it is throwing 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 Function Example 6

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

# Python List Min Function

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]