Step value and function

I

israphelr

Hi there. So I have a challenge in the Python book I am using (python
programming for the absolute beginner) that tells me to improve a
function, so that it can be called with a step value, and I havn't
been able to find out yet what's meant by a step value, but i'll keep
looking of course. I'd just be grateful if someone could illimunate
this for me.

Thanks in advance.
 
J

James Stroud

Hi there. So I have a challenge in the Python book I am using (python
programming for the absolute beginner) that tells me to improve a
function, so that it can be called with a step value, and I havn't
been able to find out yet what's meant by a step value, but i'll keep
looking of course. I'd just be grateful if someone could illimunate
this for me.

Thanks in advance.

Trivial and redundant examples, but you get the point:

def doit(start, stop):
for i in range(start, stop):
print i

def doit_step(start, stop, step):
for i in range(start, stop, step):
print i

At work:

py> doit(2, 11)
2
3
4
5
6
7
8
9
10
py> doit_step(2, 11, 2)
2
4
6
8
10
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top