Emojify - KeyError (‘funny’,)

A common mistake in this function “sentence_to_avg” is when initialzing the avg variable.
You must use the shape of a word from the word_to_vec_map dictionary.

If you use one of the words from the ‘sentence’ variable, your code will likely throw a “KeyError(…)”, because there are several different dictionaries used. The dictionaries used by the exercise test case cells are very small, and most of the sentence words you might select by hard-coding are not found in those dictionaries.

So if you use (for example) “funny” or “the” or word[0] when finding the shape for the initial avg value, you’re probably going to get a good result on the exercise data set, but will fail on the test cases and the grader.

This is why the starter code computes the variable “any_word” for you to use in the initialization of “avg”. It is selected from the first word in the dictionary that is passed to the function.