Dictionary comprehensions (dict comps) provide a convenient way to make dictionaries, just like list comps:
>>> {word.lower(): len(word) for word in ('I', 'love', 'Python')}
{'i': 1, 'love': 4, 'python': 6}One can use a dict comp to change an existing dictionary using its items method
>>> first_dict = {'i': 1, 'love': 4, 'python': 6}
>>> {key.upper(): value * 2 for key, value in first_dict.items()}
{'I': 2, 'LOVE': 8, 'PYTHON': 12}