Thats fine, but what differance does it make?<br><br>I can see no way that it improves the code.<br><br>I assume later on when the function is called, it should look as follows:<br><br>move = ask_number(&quot;Where will you move? (0-8): &quot;, 0, NUM_SQUARES, 1)
<br><br>Jon<br><br><div><span class="gmail_quote">On 01/02/06, <b class="gmail_sendername">Ed Singleton</b> &lt;<a href="mailto:singletoned@gmail.com">singletoned@gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On 31/01/06, Jon Moore &lt;<a href="mailto:jonathan.r.moore@gmail.com">jonathan.r.moore@gmail.com</a>&gt; wrote:<br>&gt; Improve the function ask_number() so that the function can be called with a<br>&gt; step value. Make the default value of step 1.
<br>&gt;<br>&gt; The function looks like this:<br>&gt;<br>&gt; def ask_number(question, low, high):<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &quot;&quot;&quot;Ask for a number within the range&quot;&quot;&quot;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; response = None<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; while response not in range(low, high):
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; response =&nbsp;&nbsp;int(raw_input(question))<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; return response<br><br>To be honest, this made sense to me.&nbsp;&nbsp;I assumed the author wants you<br>to be able to do the following:<br><br>ask_number(&quot;Give me an even number between 1 and 10&quot;, 1, 10, 2)
<br><br>The solution would be:<br><br>def ask_number(question, low, high, step=1):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;&quot;&quot;Ask for a number within the range&quot;&quot;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;response = None<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while response not in range(low, high, step):
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;response =&nbsp;&nbsp;int(raw_input(question))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return response<br><br>But I definitely agree that he said it very, very badly.<br><br>Ed<br>_______________________________________________<br>Tutor maillist&nbsp;&nbsp;-&nbsp;&nbsp;
<a href="mailto:Tutor@python.org">Tutor@python.org</a><br><a href="http://mail.python.org/mailman/listinfo/tutor">http://mail.python.org/mailman/listinfo/tutor</a><br></blockquote></div><br><br clear="all"><br>-- <br>Best Regards
<br><br>Jon Moore