python dict comprehension multiple functions code example
Example 1: 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}
Example 2: dict comprehension python
keys=['var1','var2','var3']
my_dict={key:np.zeros(10) for key in keys}