You want toggle_power to turn on or off.
class Television(object):
def __init__(self):
pass
def toggle_power(self, choice):
if choice == 0:
poweroff()
if choice == 1:
poweron()
# you set a choice that won't work unless user says
choice =
"Adrian Atkinson" wrote
class Television(object):
While using a class is not in itself a bad idea it looks like
you have much more fundamental issues to deal with so
I'd suggest dropping the class for now and just write
some functions using global variables to store the data.
You can then mo
class Television(object):
def __init__(self,__channel,volume,is_on):
self.volume = volume
self.is_on = "Power is off"
power = self.is_on
def toggle_power(self):
if choice == "1" and power == self.is_on :
power = "Power is Now on"
elif c