Python 3 - List max() Method


Advertisements

Description

The max() method returns the elements from the list with maximum value.

Syntax

Following is the syntax for max() method −

max(list)

Parameters

list − This is a list from which max valued element to be returned.

Return Value

This method returns the elements from the list with maximum value.

Example

The following example shows the usage of max() method.

#!/usr/bin/python3

list1, list2 = ['C++','Java', 'Python'], [456, 700, 200]
print ("Max value element : ", max(list1))
print ("Max value element : ", max(list2))

Result

When we run above program, it produces the following result −

Max value element :  Python
Max value element :  700
python_lists.htm
Advertisements