0
Can any one explain max(list) and min(list)
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']
+ 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
0
But when we have list that contains string thenđ€
0
Lothar thanks dude