You are viewing a single comment's thread. Return to all comments →
if name == 'main': N = int(input()) num=[] for _ in range(N): cp=input().split() c=cp[0] if c=="insert": idx=int(cp[1]) val=int(cp[2]) num.insert(idx,val) elif c=="append": val=int(cp[1]) num.append(val) elif c=="remove": val=int(cp[1]) num.remove(val) elif c=="print": print(num) elif c=="sort": num.sort() elif c=="pop": num.pop() elif c=="reverse": num.reverse()
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Lists
You are viewing a single comment's thread. Return to all comments →
if name == 'main': N = int(input()) num=[] for _ in range(N): cp=input().split() c=cp[0] if c=="insert": idx=int(cp[1]) val=int(cp[2]) num.insert(idx,val) elif c=="append": val=int(cp[1]) num.append(val) elif c=="remove": val=int(cp[1]) num.remove(val) elif c=="print": print(num) elif c=="sort": num.sort() elif c=="pop": num.pop() elif c=="reverse": num.reverse()