14 lines
273 B
Python
14 lines
273 B
Python
class Lamp:
|
|
|
|
def __init__(self, color: str):
|
|
self.color = color
|
|
self.on = False
|
|
|
|
def toggle_switch(self):
|
|
self.on = not self.on
|
|
|
|
def state(self):
|
|
if self.on:
|
|
return "The lamp is on."
|
|
return "The lamp is off."
|