Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Didn't use cycle, but did rotate through class constant containing colors solution in Clear category for Multicolored Lamp by kkkkk
class Lamp:
colors = ["Green", "Red", "Blue", "Yellow"]
def __init__(self):
self._color_idx = 0
def light(self):
"""Return the next color string in the list."""
current_color = self.colors[self._color_idx]
self._color_idx = (self._color_idx + 1) % len(self.colors)
return current_color
Jan. 2, 2020
Comments: