Step value and function
James Stroud
jstroud at mbi.ucla.edu
Sat Mar 24 20:48:42 EDT 2007
israphelr at googlemail.com wrote:
> 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
More information about the Python-list
mailing list