0

Can any one explain max(list) and min(list)

15th Feb 2020, 4:11 PM
Saurabh Sen
Saurabh Sen - avatar
4 Answers
+ 3
Saurabh Sen, if we have strings in the list it behaves like this: lst = ['h', 'a', 'x', 'e', 'ab'] print(min(lst)) # output = 'a' print(max(lst)) # output = 'x' # sorting will give: print(sorted(lst)) # output = ['a', 'ab', 'e', 'h', 'x']
16th Feb 2020, 6:00 PM
Lothar
Lothar - avatar
+ 7
Lists in python have some methods (functions) that can be used very easy. lst = [2,6,3,9,0] As you can see, the smallest element is 0, the largest element is 9. You can get these informations by using: print(min(lst)) # output = 0 print(max(lst)) # output = 9
15th Feb 2020, 4:49 PM
Lothar
Lothar - avatar
0
But when we have list that contains string thenđŸ€”
16th Feb 2020, 11:37 AM
Saurabh Sen
Saurabh Sen - avatar
0
Lothar thanks dude
19th Feb 2020, 3:31 PM
Saurabh Sen
Saurabh Sen - avatar