Step value and function

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • israphelr@googlemail.com

    #1

    Step value and function

    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.

  • James Stroud

    #2
    Re: Step value and function

    israphelr@googl email.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:

    pydoit(2, 11)
    2
    3
    4
    5
    6
    7
    8
    9
    10
    pydoit_step(2, 11, 2)
    2
    4
    6
    8
    10

    Comment

    Working...