I have a python dictionary, which looks like this.
{ 'item1' : [1,2,3,4,5,6],
'item2' : [2,3,1],
.
.
.
'item n' : [4,2,4,3,2]
}
Now my requirement is that i want to add the numeric values of this dict & to show it as :-
{ 'item1' : [21],
'item2' : [6],
.
.
.
'item n' : [15]
}
I just want the multiple values of each key to be summed up & displayed. FYI, I am using an append function. Below is my code.
for row in range(2,sheet2.max_row):
for column in "D":
cell_name = "{}{}".format(column, row)
for column2 in "P":
cell_name2 = "{}{}".format(column2,row)
arrdata2dict.setdefault(sheet2[cell_name].value,[])
arrdata2dict[sheet2[cell_name].value].append(sheet2[cell_name2].value)