You are viewing a single comment's thread. Return to all comments →
if name == 'main':
N = int(input()) lst = [] for i in range(N): lst.append(input()) out = [] for i in range(len(lst)): command = str(lst[i]).split() if command[0] == 'insert': out.insert(int(command[1]), int(command[2])) elif command[0] == 'print': print(out) elif command[0] == 'remove' and int(command[1]) in out: out.remove(int(command[1])) elif command[0] == 'append': out.append(int(command[1])) elif command[0] == 'sort': out.sort() elif command[0] == 'pop' and len(out) > 0: out.pop() elif command[0] == 'reverse': out.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':