• + 0 comments
    if __name__ == '__main__':
        N = int(input())
        lst=[]
        commands=[input().split(" ") for i in range(N)]
    
        def insert(args):
            lst.insert(args[0],args[1])
    
        def remove(args):
            lst.remove(args[0])
    
        def append(args):
            lst.append(args[0])
    
        def sort():
            lst.sort()
    
        def pop():
            lst.pop()
    
        def reverse():
            lst.reverse()
    
        def display():
            print(lst)
    
        operations={
            'insert': insert,
            'print':display,
            'remove':remove,
            'append':append,
            'sort':sort,
            'pop':pop,
            'reverse':reverse,
    
        }
    
        for command in commands:
            action=command[0]
            args =[int(i) for i in command[1:]]
            if action in operations.keys():
                if len(args)==0:
                    operations[action]()
                else:
                    operations[action](args)