How to Find Maximum Element in List in Python?
To find the maximum element in Python, you can use list max() function that returns max element from the list. Let’s understand it better with an example:
Python3
#creating a list number = [ 54 , 67 , 12 , 33 , 69 , 32 ] #printing max element print ( max (number)) |
Output
69
Python List max() Method
Python list max() function returns the maximum value present in the list.
Example:
Python3
#creating a list rand = [ 2 , 3 , 6 , 1 , 8 , 4 , 9 , 0 ] #printing max element print ( max (rand)) |
Output
9