Return multiple values in a dictionary

Viewed 32

I have been struggling with trying to code this, so any help is appreciated.

Given a string, how can I use the first letters of the words once and set them to keys, whilst adding all the words into their respective key:value pairs. How could I achieve this output, given the input.

Input:

(["foo", "bar", "based", "bee", "no"]) 

Output:

{'f': ['foo'], 'b': ['bar', 'based', 'bee'], 'n': ['no']}
0 Answers
Related