Python min() function is used to get the smallest element from the collection. This function takes two arguments, first is a collection of elements and second is key and returns the smallest element from the collection.
It has the following syntax:
It returns the smallest element from the collection.
Let's see some examples of min() function to understand it's functionality.
This example demonstrates how the min() function is used to find the smallest value among multiple numbers.
Python
Execute NowOutput:
325 1000.25
This example demonstrates how the min() function works with strings and lists in Python.
Python
Execute NowOutput:
A [10, 12]
Let us take another example to demonstrate how to find smallest string and shortest list.
Python
Execute NowOutput:
Java [13, 15]
We request you to subscribe our newsletter for upcoming updates.