I am missing something small here, and cannot for the life of me figure it out. I am trying to overwrite a dictionary value at a specific index. So for example:
dict={}
values1 = [5,10,20]
values2 = [30,40,50]
dict['key1'] = values1
dict['key2'] = values2
print(dict['key1'])
print(dict['key2'])
dict['key1'][1] = 15
print(dict['key1'])
print(dict['key2'])
returns:
[5, 10, 20]
[30, 40, 50]
[5, 15, 20]
[30, 40, 50]
Exactly as expected, it overwrote the first key, and index 1 with 15, perfect.
So why does this code below not work the same??
technicianOutput={}
monthNumList = [2,3,4,5,6]
zeroList = []
staffList = ['joe blow', 'john doe']
for x in range(len(monthNumList)):
zeroList.append(0)
for tech in staffList:
technicianOutput[tech] = zeroList
print(technicianOutput)
technicianOutput['joe blow'][0] = 1
technicianOutput['john doe'][1] = 1
print(technicianOutput)
returns:
{'joe blow': [0, 0, 0, 0, 0], 'john doe': [0, 0, 0, 0, 0]}
{'joe blow': [1, 1, 0, 0, 0], 'john doe': [1, 1, 0, 0, 0]}
I am expecting:
{'joe blow': [0, 0, 0, 0, 0], 'john doe': [0, 0, 0, 0, 0]}
{'joe blow': [1, 0, 0, 0, 0], 'john doe': [0, 1, 0, 0, 0]}