max() for strings returns the largest string in an alphabetical sense.
So max(['z', 'aaaaaaaaaa']) would return 'z'.

You need to specify an ordering function, in your case, len():

max( ['z', 'aaaaaaaa'], key=len)

...which will return 'aaaaaaaa' because it is ordering by key.


-Al Sweigart

------------------------------------
You should check out my free book for Python beginners, "Invent Your
Own Computer Games with Python"
http://inventwithpython.com
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to