[Tutor] Newbie question re. Functions

Jon Moore jonathan.r.moore at gmail.com
Tue Jan 31 10:42:05 CET 2006


I am still working my way through my 'Python for absolute beginners book'
and have hit a brick wall with one of the end of chapter exercises.

The challenge says:

Improve the function ask_number() so that the function can be called with a
step value. Make the default value of step 1.

The function looks like this:

def ask_number(question, low, high):
    """Ask for a number within the range"""
    response = None
    while response not in range(low, high):
        response =  int(raw_input(question))
    return response

The author has not eluded to 'step values' in anyway that I can see in the
proceeding chapters!


Best Regards

Jon Moore
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060131/445a95b2/attachment.html 

More information about the Tutor mailing list