• + 0 comments

    Python Solution
    This solution uses switch statements.

    if __name__ == '__main__':
        N = int(input())
        l = []
        for _ in range(N):
            command = input().split(' ')
            match command[0]:
                case 'insert':
                    l.insert(int(command[1]), int(command[2]))
                case 'print':
                    print(l)
                case 'remove':
                    l.remove(int(command[1]))
                case 'append':
                    l.append(int(command[1]))
                case 'sort':
                    l.sort()
                case 'pop':
                    l.pop()
                case 'reverse':
                    l.reverse()