I want to add 17 at the position 2 in my dictionary. When I run this code, 17 is everywhere.
dic = dict.fromkeys(range(4), [])
print("dic begin : ", dic)
dic[1].append(17)
print("dic end : ", dic)
I get this output :
('dic begin : ', {0: [], 1: [], 2: [], 3: []}) ('dic end : ', {0: [17], 1: [17], 2: [17], 3: [17]})
What am I doing wrong ?