>> 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.
Doh! Stoopid me, of course it is.
So the function is pretty much fine as it is.
Apologies,
Alan G.
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor