Suppose I have dictionary a = {} and I want to have it a result like this
value = 12
a = {'a':value,'b':value,'f':value,'h':value,'p':value}
and so on for many keys:same value. Now of course I can do it like this
a.update({'a':value})
a.update({'b':value})
and so on….
but since the value is same for all the keys, don’t we have a more pythonic approach to do this?
You could use dict comprehensions (python 2.7+):