Probably a duplicate, but I can’t find the answer by searching with these terms, at least.
Is there a quicker way to do this in Python?
level1 = {}
level2 = {}
level3 = {}
I’ve tried
level1 = level2 = level3 = {}
But that seems to create copies of the object, which isn’t what I want. And
level1, level2, level3 = {}
throws an error.
Your variable naming is a possible sign that your design could be improved. It might be better to use a list instead of three separate variables: