<br>I have a list of 2300 strings.<br><br>When I call max() on the list, it returned an item with 37 characters. I am only passing 1 argument to max().<br>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.<br>
<br>Printing len(mylist[index]) does indeed return 57 characters.<br><br>What are the assumptions when calling max on a list of strings?<br>Does the list need to be sorted? In my case, the list is sorted.<br><br>Does max have any undocumented limitations I'm not aware of?<br>
<br><title>2.1 Built-in Functions</title><link rel="STYLESHEET" type="text/css" href="lib.css"><link rel="SHORTCUT ICON" type="image/png" href="../icons/pyfav.png"><link title="Python documentation Index" rel="start" href="../index.html"><link title="Python library Reference" rel="first" href="lib.html"><link title="Contents" rel="contents" href="contents.html"><link title="Index" rel="index" href="genindex.html"><link title="About this document..." rel="last" href="about.html"><link title="About this document..." rel="help" href="about.html"><link rel="next" href="non-essential-built-in-funcs.html"><link rel="prev" href="builtin.html"><link rel="parent" href="builtin.html"><link rel="next" href="non-essential-built-in-funcs.html"><dl>
<dt>
<table cellpadding="0" cellspacing="0">
<tbody>
<tr valign="baseline">
<td><b><tt id="l2h-50" class="function">max</tt></b>(</td>
<td><var>iterable</var><big>[</big><var>,
args...</var><big>]</big><var></var><big>[</big><var>key</var><big>]</big><var></var>)</td></tr></tbody></table>
</dt><dd>With a single argument <var>iterable</var>, 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.
<p>The optional <var>key</var> argument specifies a one-argument ordering
function like that used for <tt class="method">list.sort()</tt>. The
<var>key</var> argument, if supplied, must be in keyword form (for example, "<tt class="samp">max(a,b,c,key=func)</tt>"). <span class="versionnote">Changed in
version 2.5: Added support for the optional <var>key</var> argument.</span>
</p></dd></dl><br><br>