You are viewing a single comment's thread. Return to all comments →
if name == 'main': N = int(input()) # Read the number of commands lst = [] # Initialize the list
for _ in range(N): command = input().strip().split() # Read and split command cmd = command[0] if cmd == 'insert': lst.insert(int(command[1]), int(command[2])) elif cmd == 'print': print(lst) elif cmd == 'remove': lst.remove(int(command[1])) elif cmd == 'append': lst.append(int(command[1])) elif cmd == 'sort': lst.sort() elif cmd == 'pop': lst.pop() elif cmd == 'reverse': lst.reverse()
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 →
if name == 'main': N = int(input()) # Read the number of commands lst = [] # Initialize the list