I can achieve this with
mydict = {}
for a in range(0,6):
mydict[a] = []
print (mydict)
#{0: [], 1: [], 2: [], 3: [], 4: [], 5: []}
Question is how would I achieve this with dict comprehension?
Edit:
d = {level: [] for level in range(1, level + 1)}
for each_level in d:
d[each_level] = [ExampleClass(1, 1)
for _ in range(5)]
Sorry for not putting up what I had from the beginning, I thought it would not be much help.
This is what I have and it does what I want it to be but I am wondering if there is a way I can shorten all of this into one line or so.
In the end, I would like something like:
d = {level: [] for level in range(1, level + 1), [ExampleClass(1, 1) for _ in range(5)]