[Tutor] step value
Steven D'Aprano
steve at pearwood.info
Thu Jun 16 01:52:46 CEST 2011
Vincent Balmori wrote:
> The question to that code I am trying to solve is
>
> "Improve the function ask_number() so that the function can be called with a
> step value. Make the default value of step 1."
You need to be able to tell ask_number what step function you want to
use. So it isn't enough to hard-code step=1 inside the function, step
needs to be set when you call the function.
Currently you can do this:
result = ask_number(question, low, high)
You need to be able to do this:
result = ask_number(question, low, high, step)
where step is *optional*. So you need to:
* change the ask_number function to accept a fourth argument;
* make it optional rather than required;
* give it a sensible default value;
* within the function, that value must then be passed to range
--
Steven
More information about the Tutor
mailing list