I am initializing a dictionary of empty lists. Is there a more efficient method of initializing the dictionary than the following?
dictLists = {}
dictLists['xcg'] = []
dictLists['bsd'] = []
dictLists['ghf'] = []
dictLists['cda'] = []
...
Is there a way I do not have to write dictLists each time, or is this unavoidable?
You can use collections.defaultdict it allows you to set a factory method that returns specific values on missing keys.
Edit:
Here are my keys
Now here is me using the “predefined keys”