[Tutor] Step Value
Vincent Balmori
vincentbalmori at yahoo.com
Fri Jun 17 20:05:47 CEST 2011
Here is my updated code. As simple as this may be, I am a little lost again.
I appreciate the help and explanations to try to push me to get this on my
own, but 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.
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
-Vincent
Alan Gauld wrote:
>
>
> "Vincent Balmori" <vincentbalmori at yahoo.com> wrote
>
> "def spam(n=3):
> """Return n slices of yummy spam."""
> return "spam "*n
>
>
>> This is my new code for a default step value based on your feedback
>> Steve:
>>
>> def ask_number(question, low, high, step):
>> """Ask for a number within a range."""
>> response = None
>> if step == None:
>> step = 1
>
> Nope, you are still missing the point.
> Look again at how Steven defined his function.
> What is different about his definition of n and your definition of
> step?
>
> HTH,
>
> --
> Alan Gauld
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>
--
View this message in context: http://old.nabble.com/-Tutor--Step-Value-tp31865967p31871108.html
Sent from the Python - tutor mailing list archive at Nabble.com.
More information about the Tutor
mailing list