0

I'm a python beginner and I have a question. I defined:

s = 'Manchester united is the best football team'
l = s.split(' ')
max(l)

The final answer was united, but I expected it should have been Manchester, because: len(l[0]) = 10 and len(l[1]) = 6.

Is there someone to answer my question?

julien.leroux5
  • 969
  • 7
  • 17
Mary
  • 3
  • 1
  • 1
    Does this answer your question? [How does the max() function work on list of strings in python?](https://stackoverflow.com/questions/20463204/how-does-the-max-function-work-on-list-of-strings-in-python) – mlueckl Oct 07 '21 at 14:29
  • 1
    max takes the last item sorted. So if you sort that list in alpha order, the max/last item will be `'united'`. Try `s = 'Manchester united is za best football team'`, and it will return `'za'` – chitown88 Oct 07 '21 at 14:32

1 Answers1

-2

This was already answered here stackoverflow.com/a/20463240/964862

mlueckl
  • 198
  • 11