Python 3 - Tuple max() Method


Advertisements

Description

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

Syntax

Following is the syntax for max() method −

max(tuple)

Parameters

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

Return Value

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

Example

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

#!/usr/bin/python3

tuple1, tuple2 = ('maths', 'che', 'phy', 'bio'), (456, 700, 200)
print ("Max value element : ", max(tuple1))
print ("Max value element : ", max(tuple2))

Result

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

Max value element :  phy
Max value element :  700
python_tuples.htm
Advertisements