Week2 Emojify_v3a key error

Hi all,
I am stuck at the same code segment.

It so far seems to work, however, the notebook throws an error

KeyError: ‘love’

Even though the notebook seems to work well (All tests passed), the grader score is 0. The grader output is:
### START CODE HERE ###
# Step 1: Split sentence into list of lower case words (≈ 1 line)
words = sentence.lower().split()

# Initialize the average word vector, should have the same shape as your word vectors.
avg = np.zeros(word_to_vec_map[any_word].shape)

# Initialize count to 0
count = 0

# Step 2: average the word vectors. You can loop over the words in the list "words".
for w in words:
    # Check that word exists in word_to_vec_map
    if w in words:
        avg += word_to_vec_map[w]
        # Increment count
        count +=1
      
if count > 0:
    # Get the average. But only if count > 0
    avg = avg/len(words)

### END CODE HERE ###

Cell #13. Can’t compile the student’s code. Error: KeyError(‘never’,)

I have no idea what causes this. Any help appreciated

I got the same issue!

Same problem here. And I get 0/100 when I submit even though everything else works well.

@A47 you have to use word_to_vec_map in if in for loop instead of words and for calculating avg use:
avg = avg / count
not divided by len(words)

2 Likes

Indeed, I corrected that already without notifying you. My apologies