• + 0 comments

    I prefer this one too, I improved a little bit:

    L = []
    for i in range(N):
        s = input().split(" ")
        arg = list(map(int, s[1:]))
        if s[0] == 'insert':
            L.insert(*arg)
        elif s[0] == 'remove':
            L.remove(*arg)
        elif s[0] == 'append': 
            L.append(*arg)
        elif s[0] == 'sort': 
            L.sort()
        elif s[0] == 'pop':
            L.pop()
        elif s[0] == 'reverse':
            L.reverse()
        else:
            print(L)