You are viewing a single comment's thread. Return to all comments →
if __name__ == '__main__': list=[] N = int(input()) i = [] for functions in range(N): i.append(input()) orders =[] for items in i : orders.append(items.split()) for l in range(N): if len(orders[l]) == 3: num= int(orders[l][1]) position = int(orders[l][2]) list.insert(num,position) elif len (orders[l]) == 2: num = int(orders[l][1]) if orders[l][0] == "remove": list.remove(num) elif orders[l][0] == "append": list.append(num) elif len(orders[l]) == 1 : if orders[l] == ["print"]: print(list) elif orders[l] == ["sort"]: list.sort() elif orders[l] == ["pop"]: list.pop() elif orders[l] == ["reverse"]: 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 →