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
2
  • 2
    max is going to find the lexicographically-largest item in the list first, before converting it to int. Commented Feb 4, 2018 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 Commented Feb 4, 2018 at 14:30

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.