iterating over a list as if it were a circular list

Chris Angelico rosuav at gmail.com
Thu Mar 7 10:28:02 CET 2013


On Thu, Mar 7, 2013 at 8:23 PM, Sven <svenito at gmail.com> 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



More information about the Python-list mailing list