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