• + 22 comments

    This worked first try. Thought I would share because so many seemed to be having issues. I've been in the habit of always using raw_input().strip() or input().strip() (Python 3). It saves you many headaches trying to figure out non-printable characters.

    I didn't bother with a map statement. Probably could have wrapped it in a try block, but it still passes. :)

    T = int(raw_input().strip())
    
    L = []
    for t in range(T):
        args = raw_input().strip().split(" ")
        if args[0] == "append":
            L.append(int(args[1]))
        elif args[0] == "insert":
            L.insert(int(args[1]), int(args[2]))
        elif args[0] == "remove":
            L.remove(int(args[1]))
        elif args[0] == "pop":
            L.pop()
        elif args[0] == "sort":
            L.sort()
        elif args[0] == "reverse":
            L.reverse()
        elif args[0] == "print":
            print L