Easy Tutorial
❮ Python Operator Python Quicksort ❯

Python Finding the Maximum Element in a List

Python3 Examples

Define a list of numbers and find the maximum element in the list.

For example:

Input : list1 = [10, 20, 4]
Output : 20

Example 1

list1 = [10, 20, 4, 45, 99] 
  
list1.sort() 
  
print("The maximum element is:", list1[-1])

The output of the above example is:

The maximum element is: 99

Example 2: Using the max() Method

list1 = [10, 20, 1, 45, 99] 
  
print("The maximum element is:", max(list1))

The output of the above example is:

The maximum element is: 99

Python3 Examples

❮ Python Operator Python Quicksort ❯