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)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

AWS Security LIVE!

Hosted by security experts, AWS Security LIVE! showcases AWS Partners tackling real-world security challenges. Join live and get your security questions answered.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️