You are viewing a single comment's thread. Return to all comments →
lst=[] n=int(input())
for i in range(n): command = input().split() # "insert 10 5" ==> after split ["insert","10","5"]
if command[0]=='insert': lst.insert(int(command[1]),int(command[2])) elif command[0]=='print': print(lst) elif command[0]=='remove': lst.remove(int(command[1])) elif command[0]=='append': lst.append(int(command[1])) elif command[0]=='sort': lst.sort() elif command[0]=='pop': lst.pop() elif command[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 →
lst=[] n=int(input())
for i in range(n): command = input().split() # "insert 10 5" ==> after split ["insert","10","5"]