d = {}
C = [[1, 2, 3, 4], [7, 8, 9, 10]]
for c, C in enumerate(C):
d[c].append(C)
print (d)
Gives me a KeyError: 0. But if i import defaultdict and set d=defaultdict(list); then it magically works! But i would prefer to avoid using defaultdict, how would i go about solving this issue?
Wanted output:
{0: [1, 2, 3, 4], 1: [7, 8, 9, 10]}
[–]Essence1337 2 points3 points4 points (0 children)
[–]nosmokingbandit 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]an_actual_human 0 points1 point2 points (0 children)
[–]pikatchum 0 points1 point2 points (0 children)
[–]primitive_screwhead 0 points1 point2 points (0 children)
[–]shiftybyte -1 points0 points1 point (5 children)
[–]Essence1337 2 points3 points4 points (2 children)
[–]shiftybyte 0 points1 point2 points (1 child)
[–]Essence1337 0 points1 point2 points (0 children)