Re: iterating over a list as if it were a circular list

Discussion in 'Python' started by Chris Angelico, Mar 7, 2013.

  1. On Thu, Mar 7, 2013 at 8:23 PM, Sven <> wrote:
    > Now I would like to iterate over P and place one N at each point. However if
    > you run out of N I'd like to restart from N[0] and carry on until all the
    > points have been populated.


    Check out itertools.cycle, it should do what you want.

    ChrisA
     
    Chris Angelico, Mar 7, 2013
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sven
    Replies:
    1
    Views:
    166
    Roy Smith
    Mar 7, 2013
  2. Sven
    Replies:
    3
    Views:
    173
    Steven D'Aprano
    Mar 8, 2013
  3. Chris Rebert
    Replies:
    0
    Views:
    133
    Chris Rebert
    Mar 7, 2013
  4. Sven
    Replies:
    0
    Views:
    130
  5. Chris Rebert
    Replies:
    0
    Views:
    147
    Chris Rebert
    Mar 7, 2013
Loading...

Share This Page