How to delete a subdocument from an array of documents where <condition>?

I thought I had gotten quite comfortable with mongodb until I ran in to the following issue. I have a collection of documents in the following format:

{
    "_id" : ObjectId("4f876104d976649cbb1f6cf2"),
    "course_list" : [
        {
            "course_id" : "AL101",
            "Grade" : "A"
        },
        {
            "course_id" : "PS101",
            "Grade" : "B"
        },
        {
            "course_id" : "EL101",
            "Grade" : "B"
        }
    ],
    "user_name" : "jim"
}

I want to delete all sub-documents from the array "course_list" where "Grade" is NOT EQUAL to "A".

I tried a bunch of different queries, but nothing worked. But then, I thought the following would work for sure, but it didnt either:

db.courses.update({'user_name' : 'jim'}, {$pull : {'course_list' : {'Grade' : {$ne : 'A'}}}})

I get the following array when I run the above command:

Cannot apply $pull/$pullAll modifier to non-array

Can anyone point me in the right direction, please?

JohnnyHK,

Thanks for your comment. My query was indeed correct. The error, as you rightly pointed out, was because of a document where course_list wasn't an array.

--su