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 choice =="1" and power =="Power is Now on" : power = self.is_on print power def instructions(): print "0 - Exit" print "1 - Toggle Power" print "2 - Change Channel" print "3 - Raise Volume" print "4 - Lower Volume" #Main choice = "" while choice != 0: choice = raw_input("Can I have a selection number? : ") tv = Television(0,50,"is_on") tv.toggle_power() I'm trying to make a toggle to turn the power on and off in the toggle_power method but I cannot figure this out. Any help would be greatly appreciated
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor