To get the minimum of a list of numbers or strings in Python, we can use the Python **min()** function. You can use the min() function in Python to get the minimum value of numbers in a list, strings in a list, and values in a dictionary.

```
list_of_numbers = [10,32,98,38,47,34]
print(min(list_of_numbers))
#Output
10
```

There are many powerful built-in functions in the Python language which allow us to perform basic or complex tasks easily.

One such task is to find the minimum value of a collection of numbers or strings.

We can use the Python **min()** function to find the minimum, or smallest, value in an iterable (list, dictionary, set, etc.) made up of numbers or strings.

Let’s say we have the following list of numbers in Python. We can use the Python built-in **min()** function to get the minimum value of the list in the following way:

```
list_of_numbers = [10,32,98,38,47,34]
print(min(list_of_numbers))
#Output
10
```

We can also call the **min()** function with multiple arguments. In this case, **min()** returns the smallest value of the arguments.

```
print(min(10,32,98,38,47,34))
#Output
10
```

For a collection of strings, the smallest value is determined after sorting alphabetically.

```
print(min("Mike","Alex","Patricia"))
#Output
Abby
```

If you instead want to find the maximum value of an iterable, you can use the Python max() function.

If you are using pandas in Python and want to get the minimum value of a column or DataFrame, you can use the pandas min() function.

## How to Find Minimum of Two Numbers Using Python min() Function

In Python, we can easily find the minimum of two numbers using the **min()** function.

Below are a few examples of getting the min value between two numbers using **min()**.

```
print(min(10,32))
print(min(-30,4))
print(min(40,-21))
print(min(8,-22))
print(min(98,99))
#Output
10
-30
-21
-22
98
```

## How to Find Smallest Value in List of Numbers Using Python min() Function

We can use the Python **min()** function to get the smallest value in a list of numbers easily. To find the min value of a list, we just pass the list to **min()**.

Let’s say we have the following list of numbers.

`list_of_numbers = [10,32,98,38,47,34]`

To get the minimum value of a list of numbers in Python, we use the **min()** function.

```
list_of_numbers = [10,32,98,38,47,34]
print(min(list_of_numbers))
#Output
10
```

## How to Get Minimum Value in List of Strings Using Python min() Function

We can use the Python **min()** function to get the smallest value in a list of strings easily. To find the min value of a list, we just pass the list to **min()**.

The smallest value from a list of strings is the first string in alphabetical order from A to Z, meaning the string that starts with a letter closest to A will be the smallest. Also, note that uppercase letters come before lowercase letters.

Let’s say we have the following list of strings.

`list_of_strings = ["Low","High","Better","Worse"]`

To get the minimum value of a list of strings in Python, we use the **min()** function.

```
list_of_strings = ["Low","High","Better","Worse"]
print(min(list_of_strings))
#Output
Low
```

## How to Find Minimum Value in Dictionary Using Python min() Function

With the Python **min()** function, we can find the minimum value in a dictionary.

Let’s say we have the following dictionary.

`dict = { "Alex": -3, "John":5, "Tammy":-10, "Jim":4 }`

To get the min value in a dictionary, we pass the dictionary to **min()** as shown in the following Python code.

```
dict = { "Alex": -3, "John":5, "Tammy":-10, "Jim":4 }
print(min(dict))
#Output:
-3
```

We can also get the minimum value of the keys in a dictionary. To do so, we need to pass a lambda expression for min() as the “key”.

Below is how to find the min value of the keys in a dictionary in Python.

```
dict = { "Alex": -3, "John":5, "Tammy":-10, "Jim":4 }
print(min(dict, key = lambda k: dict[k]))
#Output:
Alex
```

Hopefully this article has been useful for you to learn how to use the Python **min()** function to get the minimum value of a list of numbers or strings.

## Leave a Reply