On 12/4/2009 12:08 PM, Tony Cappellini wrote:
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.
max determines whether one is larger than the other with "<" operator. max on a list of string will determine the last item if the list has been sorted in lexicographical order (i.e. the item closest to z, in a list of string with alphanumerics characters only).
If you want the longest string use: _, longest = max((len(s), s) for s in mylist) _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
