ItSolutionStuff.com

Python Smallest and Largest Numbers in a List Example

By Hardik Savani • October 30, 2023
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: Python
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

How to Get Largest Number in List Python?

Read Now →

How to Create a List of Numbers from 1 to 100 in Python?

Read Now →

How to Check If Element is Present in List Python?

Read Now →

How to Check If a List is Empty or Not in Python?

Read Now →

How to Add Multiple Elements to a List in Python?

Read Now →

How to Count Number of Elements in a List in Python?

Read Now →

Python List Print All Elements Except First Example

Read Now →

How to Get Min Value from Python List?

Read Now →

Python Split String into List of Characters Example

Read Now →

How to Convert String into List in Python?

Read Now →

How to Get Unique Elements from List in Python?

Read Now →

Python Remove Empty String from List Example

Read Now →

How to Remove Last Element from List in Python?

Read Now →