Python List max() Method
This tutorial is for the Python List max() Method. Python list method max returns the elements from the list with maximum value. Python max() method will return the maximum value. the task is to write a Python program to find the largest number in the given list.
Using sort() method
# Python List max() Method list1 = [300, 209, 102, 160, 500, 980, 700, 560] # sorting the list list1.sort() # print the last element print("The largest element is:", list1[-1]) Output The largest element is: 980
Using max() method
list1 = ['abc', 'devnote', 'xuz', 'xtz'] list2 = [400, 401, 700, 705, 709, 890] print ("Max value is : ", max(list1)) print ("Max value is : ", max(list2)) Output Max value is : xuz Max value is : 890