Example 3: Using max for equal-length elements
Here we are finding the maximum element among the tuple of equal length elements. Where it gives the lexicographically largest string.
Python3
# alphabets tuple alphabets = ( 'GFG' , 'gfg' , 'gFg' , 'GfG' , 'Gfg' ) res = max (alphabets) print ( 'Maximum of Tuple is' , res) |
Output:
Maximum of Tuple is gfg
Python Tuple – max() Method
While working with tuples many times we need to find the maximum element in the tuple, and for this, we can also use max(). In this article, we will learn about the max() method used for tuples in Python.
Example
Tuple =( 4, 2, 5, 6, 7, 5)
Input:
max(Tuple)
Output: 7
Explanation: The max() method returns the largest element of the given tuple.
Contact Us