How do I create a dictionary of lists? Here is what I tried:
zigzag = dict.fromkeys(range(1, 4),[])
for i in range(1, 4):
zigzag[i].extend(range(i, 13 , 4))
What I expected to get was:
{
1: [1,5,9,13],
2: [2,6,10],
3: [3,7,11]
}
But the actual result had the same list in each value:
{
1: [1, 5, 9, 2, 6, 10, 3, 7, 11],
2: [1, 5, 9, 2, 6, 10, 3, 7, 11],
3: [1, 5, 9, 2, 6, 10, 3, 7, 11]
}
I don't know how that result happened. How can I get my expected answer?