dictionary comprehensions in python 3 code example
Example 1: create dictionary comprehension python
{key:value for key in iterable}
Example 2: python set and dictionary comprehensions
simple_dict = {
'a': 1,
'b': 2
}
my_dict = {key: value**2 for key,value in simple_dict.items()}
print(my_dict)
#result = {'a': 1, 'b': 4}