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())
l=list()
for op in range(N):
inputs=input().split()
operation=inputs[0]
if operation=='insert':
l.insert(int(inputs[1]),int(inputs[2]))
elif operation=='pop' or operation=='reverse' or operation=='sort':
eval(f"l.{operation}()")
elif operation=='print':
print(l)
else:
method=f"l.{operation}({int(inputs[1])})"
eval(method)
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()) l=list() for op in range(N): inputs=input().split() operation=inputs[0] if operation=='insert': l.insert(int(inputs[1]),int(inputs[2])) elif operation=='pop' or operation=='reverse' or operation=='sort': eval(f"l.{operation}()") elif operation=='print': print(l) else: method=f"l.{operation}({int(inputs[1])})" eval(method)