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

Python3 List max() Method

Python3 List max() Method

Python3 Lists The Python3 list


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:

Example

#!/usr/bin/python3

list1

,

list2

=

[

'Google'

,

'Runoob'

,

'Taobao'

]

,

[

456

,

700

,

200

]

print

(

"Largest element in list1: "

,

max

(

list1

)

)

print

(

"Largest element in list2: "

,

max

(

list2

)

)

The output of the above example is:


list1 最大元素值 :  Taobao
list2 最大元素值 :  700

Python3 Lists The Python3 list