DEV Community

realNameHidden
realNameHidden

Posted on

1 1 1 1 1

lists in python hackerrank solution

For Explanation watch the video

code ::

if __name__ == '__main__':
    N = int(input())
    L = []
    for i in range(N):
        cmd = input().split()
        if cmd[0]=='insert':
            L.insert(int(cmd[1]),int(cmd[2]))
        elif cmd[0]=='print':
            print(L)
        elif cmd[0]=='remove':
            L.remove(int(cmd[1]))
        elif cmd[0]=='append':
            L.append(int(cmd[1]))
        elif cmd[0]=='sort':
            L.sort()
        elif cmd[0]=='pop':
            L.pop()
        elif cmd[0]=='reverse':
            L.reverse()
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay