Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
class VoiceCommand(list) solution in Clear category for Voice TV Control by David_Jones
class VoiceCommand(list):
def __init__(self, channels):
super().__init__(channels)
self.number = 0
def first_channel(self):
self.number = 0
return self.current_channel()
def last_channel(self):
self.number = len(self) - 1
return self.current_channel()
def turn_channel(self, N):
self.number = N - 1
return self.current_channel()
def next_channel(self):
self.number = (self.number + 1) % len(self)
return self.current_channel()
def previous_channel(self):
self.number = (self.number - 1) % len(self)
return self.current_channel()
def current_channel(self):
return self[self.number]
def is_exist(self, name):
if (
name in self
or isinstance(name, int) and 0 <= name < len(self)
):
return 'Yes'
return 'No'
June 24, 2019
Comments: