How to use min() Method to find smallest number in a list In Python
Here we are using the min Method and then returning the smallest element present in the list.
Python3
# Python program to find smallest # number in a list # list of numbers list1 = [ 10 , 20 , 1 , 45 , 99 ] # printing the minimum element print ( "Smallest element is:" , min (list1)) |
Output:
Smallest element is: 1
Time Complexity: O(n)
Auxiliary Space: O(n), where n is length of list
Python program to find smallest number in a list
We are given a list of numbers and our task is to write a Python program to find the smallest number in given list. For the following program we can use various methods including the built-in min method, sorting the array and returning the last element, etc.
Example:
Input : list1 = [10, 20, 4] Output : 4 Input : list2 = [20, 10, 20, 1, 100] Output : 1
Contact Us