<div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><br><div>I suspect I've found a documentation error in the above mentioned link (<a href="http://docs.python.org/library/random.html" target="_blank">http://docs.python.org/library/random.html</a>); regarding random.randint(a, b), the documentation says "Return a random integer N such that a <= N <= b", however when actually using the function, it does seem to be a <= N < b.</div>
<div> </div>
<div>Running Python 2.6, the built-in help returns</div>
<div> </div>
<div>Type: builtin_function_or_method<br>Base Class: <type 'builtin_function_or_method'><br>String Form: <built-in method randint of mtrand.RandomState object at 0x01466<br>340><br>Namespace: Interactive<br>
Docstring:<br> randint(low, high=None, size=None)</div>
<div>Return random integers from `low` (inclusive) to `high` (exclusive).</div>
<div>Return random integers from the "discrete uniform" distribution in the<br>"half-open" interval [`low`, `high`). If `high` is None (the default),<br>then results are from [0, `low`).</div>
<div><br></div></blockquote><div><br>randint indeed includes both endpoints: <br></div><div><br>>>> for i in range(10):<br>... print random.randint(0, 1)<br>... <br>1<br>1<br>1<br>1<br>0<br>0<br>1<br>0<br>0<br>
0 <br><br>Its help string agrees:<br><br>>>> help(random.randint)<br>Help on method randint in module random:<br><br>randint(self, a, b) method of random.Random instance<br> Return random integer in range [a, b], including both end points.<br>
<br><br></div></div></div>