Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python List max() method

Python List max() method

Python Lists Python Lists


Description

The max() method returns the largest element in a list.

Syntax

max() method syntax:



max(list)

Parameters

Return Value

Returns the largest element in the list.

Example

The following example shows how to use the max() function:



#!/usr/bin/python



list1, list2 = ['123', 'xyz', 'zara', 'abc'], [456, 700, 200]



print "Max value element : ", max(list1);

print "Max value element : ", max(list2);

The output of the above example is:



Max value element :  zara

Max value element :  700

Python Lists Python Lists