How to Get Max Value from List in Python?

05-Nov-2022

.

Admin

How to Get Max Value from List in Python?

Hi Dev,

In this post, we will learn how to get max value from list in python. step by step explain get max value from list in python. it's simple example of how to get max value from python list. This tutorial will give you simple example of python find max value in list of objects.

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

so let's see following examples with output:

Example 1:


main.py

myList = [10, 100, 20, 200, 50]

# Get Max number from List

maxValue = max(myList)

print(maxValue)

Output:

200

Example 2:

main.py

myList = [10, 100, 20, 200, 50]

# Get Max number from List

myList.sort()

maxValue = myList[-1]

print(maxValue)

Output:

200

#Python