Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Multicolored Lamp by _Chico_
from itertools import cycle
class Lamp: from itertools import cycle
class Lamp:
def __init__(self):
colors = ["Green", "Red", "Blue", "Yellow"]
self.state = cycle(colors)
def light(self):
return next(self.state)
June 12, 2021