Skip to main content

Practice · 2 of 2

Finite Cycler

CHALLENGE
Difficulty: intermediate+25 XP

Create a class Cycler(items) that loops over a finite list forever when used with next() directly, BUT supports it = iter(c) producing an iterator that cycles. Implement it as an iterator whose __next__ wraps around using modulo.

Back to lesson: Practice: Iterator Drills