We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
if name == 'main':
N = int(input())
fin=[]
for i in range(N):
value=input()
value=value.split()
if value[0]=='insert':
fin.insert(int(value[1]),int(value[2]))
if value[0]=='print':
print(fin)
if value[0]=='remove':
fin.remove(int(value[1]))
if value[0]=='sort':
fin.sort()
if value[0]=='reverse':
fin.reverse()
if value[0]=='pop':
fin.pop()
if value[0]=='append':
fin.append(int(value[1]))
Cookie support is required to access HackerRank
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()) fin=[] for i in range(N): value=input() value=value.split() if value[0]=='insert': fin.insert(int(value[1]),int(value[2])) if value[0]=='print': print(fin) if value[0]=='remove': fin.remove(int(value[1])) if value[0]=='sort': fin.sort() if value[0]=='reverse': fin.reverse() if value[0]=='pop': fin.pop() if value[0]=='append': fin.append(int(value[1]))