You are viewing a single comment's thread. Return to all comments →
if name == 'main': N = int(input()) lst = [] for i 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() elif cmd[0] == 'reverse': lst.reverse() else: pass
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()) lst = [] for i 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() elif cmd[0] == 'reverse': lst.reverse() else: pass