1

Could you please help me why the below code is not working for max and min function in list?

mylist = [ '6','12','13','13','12','10','6','11','5']
set(mylist)
set(['11', '10', '13', '12', '5', '6'])
int(max(mylist))
6
int(min(mylist))
10
int(min(mylist))
10
vaultah
  • 44,105
  • 12
  • 114
  • 143
  • 2
    `max` is going to find the lexicographically-largest item in the list first, before converting it to int. – wkl Feb 04 '18 at 14:27
  • 2
    Use `max(mylist, key=int)` if you want your code to work, but ideally you should use a list of ints to begin with – Andrea Corbellini Feb 04 '18 at 14:30

0 Answers0