Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Multicolored Lamp by hidebehind3
from itertools import cycle
class Lamp:
colors = ('Green', 'Red', 'Blue', 'Yellow')
def __init__(self):
self._color = None
self._cycle = cycle(self.colors)
def light(self):
self._color = next(self._cycle)
return self._color
Oct. 30, 2018
Comments: