You are viewing a single comment's thread. Return to all comments →
if __name__ == "__main__": N = int(input()) operations: list[tuple[str, list[int]]] = [("", [])] operations = [ (command, list(map(int, arguments))) for command, *arguments in (input().split() for _ in range(N)) ] my_list: list[int] = [] for command, arguments in operations: match command: case "insert": my_list.insert(arguments[0], arguments[1]) case "print": print(my_list) case "remove": my_list.remove(arguments[0]) case "append": my_list.append(arguments[0]) case "sort": my_list.sort() case "pop": my_list.pop() case "reverse": my_list.reverse() case _: raise ValueError(f"Unknown command: {command}")
Seems like cookies are disabled on this browser, please enable them to open this website
Lists
You are viewing a single comment's thread. Return to all comments →