On Fri, Jun 17, 2011 at 11:03 PM, Alan Gauld <alan.ga...@btinternet.com> wrote:
>
> "Vincent Balmori" <vincentbalm...@yahoo.com> wrote
>
>> Here is my updated code. As simple as this may be, I am a little lost
>> again.
>
> I'm not sure why you are lost because that's pretty much it.
>
>> ... at this point (especially after one week) this is when me being
>> given the answer with an explanation will help me much more, so I can
>> understand how it works better.
>
> The answer is:
>
>> def ask_number(question, low, high, step = 1):
>>   """Ask for a number within a range."""
>>   response = None
>>   while response not in range(low, high, step):
>>       response = int(input(question))
>>   return response
>
> With the only comment being that you don't really need the
> response=None line because response always gets set
> inside the loop.

But the value of response is used in starting the loop (it is needed
to test whether the loop should be gone through a first time), so one
_does_ need that line.


-- 
André Engels, andreeng...@gmail.com
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to