You are viewing a single comment's thread. Return to all comments →
if __name__ == '__main__': N = int(input()) # number of commands mylist=[] for i in range(N): cmd=input().strip().split() #command if cmd[0]=="insert": mylist.insert(int(cmd[1]),int(cmd[2])) elif cmd[0]=="print": print(mylist) elif cmd[0]=="remove": mylist.remove(int(cmd[1])) elif cmd[0]=="append": mylist.append(int(cmd[1])) elif cmd[0]=="sort": mylist.sort() elif cmd[0]=="pop": mylist.pop() elif cmd[0]=="reverse": mylist.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 →