You are viewing a single comment's thread. Return to all comments →
if __name__ == '__main__': mylist = [] N = int(input().strip()) for _ in range(N): cmd = input().strip().split() if cmd[0] == "insert": mylist.insert(int(cmd[1]), int(cmd[2])) elif cmd[0] == "print": print(mylist) elif cmd[0] == "remove": mylist.remove(int(cmd[1])) elif cmd[0] == "append": mylist.append(int(cmd[1])) elif cmd[0] == "sort": mylist.sort() elif cmd[0] == "pop": mylist.pop() elif cmd[0] == "reverse": mylist.reverse() else: print(f"Invalid command: {cmd[0]}")
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 →