I have a list of 2300 strings. When I call max() on the list, it returned an item with 37 characters. I am only passing 1 argument to max(). I know for a fact that the largest item has 57 characters, and when I called mylist.index('my_57_character_string') the index was found.
Printing len(mylist[index]) does indeed return 57 characters. What are the assumptions when calling max on a list of strings? Does the list need to be sorted? In my case, the list is sorted. Does max have any undocumented limitations I'm not aware of? 2.1 Built-in Functions *max*( iterable[, args...][key]) With a single argument iterable, return the largest item of a non-empty iterable (such as a string, tuple or list). With more than one argument, return the largest of the arguments. The optional key argument specifies a one-argument ordering function like that used for list.sort(). The key argument, if supplied, must be in keyword form (for example, "max(a,b,c,key=func)"). Changed in version 2.5: Added support for the optional key argument.
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor