You are viewing a single comment's thread. Return to all comments →
if name == 'main': N = int(input()) my_list = [] for _ in range(N): inp=input().split() if(inp[0] == 'insert'): my_list.insert(int(inp[1]) , int(inp[2])) elif(inp[0] == 'print'): print(my_list) elif(inp[0] == 'remove'): my_list.remove(int(inp[1])) elif(inp[0] == 'append'): my_list.append(int(inp[1])) elif(inp[0] == 'sort'): my_list.sort() elif(inp[0] == 'pop'): my_list.pop() elif(inp[0] == 'reverse'): my_list.reverse()
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Lists
You are viewing a single comment's thread. Return to all comments →
if name == 'main': N = int(input()) my_list = [] for _ in range(N): inp=input().split() if(inp[0] == 'insert'): my_list.insert(int(inp[1]) , int(inp[2])) elif(inp[0] == 'print'): print(my_list) elif(inp[0] == 'remove'): my_list.remove(int(inp[1])) elif(inp[0] == 'append'): my_list.append(int(inp[1])) elif(inp[0] == 'sort'): my_list.sort() elif(inp[0] == 'pop'): my_list.pop() elif(inp[0] == 'reverse'): my_list.reverse()