class Menu: def __init__(self, selects: list): self.selects = selects self.cursor = 0 def to_the_right(self): self.cursor = (self.cursor + 1) % len(self.selects) def to_the_left(self): self.cursor = (self.cursor - 1) % len(self.selects) def display(self): return ( "[" + ", ".join( [ f"'{s}'" if i != self.cursor else f"['{s}']" for i, s in enumerate(self.selects) ] ) + "]" ) if __name__ == "__main__": menu = Menu(["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]) print(menu.display()) menu.to_the_right() print(menu.display()) menu.to_the_left() menu.to_the_left() menu.to_the_left() print(menu.display()) menu.to_the_left() menu.to_the_left() print(menu.display())