Python Smallest and Largest Numbers in a List Example

By Hardik Savani October 30, 2023 Category : Python

Hey Developer,

Now, let's see post of python smallest and largest numbers in a list. I would like to show you smallest and largest numbers in a list python. This post will give you a simple example of python biggest number in a list. I explained simply about find the lowest number in a list python. follow the below step for python smallest and largest numbers in a list.

There are a few ways to get the smallest and largest number from the list in python. i will give you two examples using for loop with min() to get max and min number from list. so let's see the below examples.

You can use these examples with python3 (Python 3) version.

let's see below a simple example with output:

Example 1:

main.py

myList = [10, 100, 20, 200, 50]
  
# Python Smallest and Largest Numbers in a List Example
minValue = min(myList)
maxValue = max(myList)
  
print(minValue)
print(maxValue)

Output:

10
200

Example 2:

main.py

myList = [10, 100, 20, 200, 50]
  
# Python Smallest and Largest Numbers in a List Example
myList.sort()
minValue = myList[0]
maxValue = myList[-1]
  
print(minValue)
print(maxValue)

Output:

10
200

I hope it can help you...

Tags :
Shares