I have a list ['a','b','c','d']. I need to construct a dict out of this list with all the elements of the list as keys in the dict with some default value for all the elements such as None.
How to do that? Should I need to write a function for that or is there a constructor available?
See
dict.fromkeys().dict.fromkeys(['a','b','c','d'])will return a dictionary withNonefor all of its values.dict.fromkeys(['a','b','c','d'], foo)will return a dictionary withfoofor all of its values.