Day 40: Create Dictionary Comprehension

There are many other objects you can build using comprehensions, such as dictionaries, pervasive objects in Data Science. Main difference between a list comprehension and a dict comprehension is the use of curly braces {} instead of []. Additionally, members of the dictionary are created using a colon (:) as in <key> : <value> as the output expression.

The syntax:

[output expressionforiterator variableiniterable].

DataCamp’s example:

Another sample code I extracted from DataCamp’s tutorial to output the fellowship’s name and its length in key-value pair.