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