How to specify where to start in an itertools.cycle function
问题 I need to cycle through a list for starting position between 1-4 using itertools I am able to cycle through the list positions = itertools.cycle([1,2,3,4]) next(positions) This does return the next position, but what if the next time I need to start at 3? How can I set the start position? I need the start position to change often, I cant just change the list to start at 3. 回答1: You can't set a starting position; it'll always start where the given sequence starts. You can move the cycle along