Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
23-liner: Your TV have been controlled succesfully (Detailed Code) solution in Clear category for Voice TV Control by Stensen
class VoiceCommand:
def __init__(self, channels):
self.channels, self.current = channels, channels[0]
def first_channel(self):
self.current = self.channels[0]
return self.current
def last_channel(self):
self.current = self.channels[-1]
return self.current
def turn_channel(self, N):
self.current = self.channels[N-1]
return self.current
def next_channel(self):
index = self.channels.index(self.current) + 1
self.current = self.channels[index if index < len(self.channels) else 0]
return self.current
def previous_channel(self):
index = self.channels.index(self.current) - 1
self.current = self.channels[index if index > 0 else -1]
return self.current
def current_channel(self): return self.current
def is_exist(self, channel):
return 'Yes' if channel in self.channels or channel in range(len(self.channels)) else 'No'
Oct. 15, 2020