mercredi 18 février 2015

Update value from one default dictionary with another in python 3.x


Vote count:

0




I have two default dictionaries like



dict_1 = {0: [7, 7, 6, 5, 2, 1], -40: [4], -50: [2], -10: [4]}
dict_2 = {0: [1, 1, 1, 1, 0, 0, 1, 0, 1], -40: [0, 0, 0, 0, 0, 1, 0, 0, 0], -10: [0, 0, 0, 0, 1, 0, 0, 0, 0], -50: [0, 0, 0, 0, 0, 0, 0, 1, 0]})


I want to add corresponding value from dict_1 to dict_2 as followed.



dict_2 = {0: [7, 7, 6, 5, 0, 0, 2, 0, 1], -40: [0, 0, 0, 0, 0, 4, 0, 0, 0], -10: [0, 0, 0, 0, 4, 0, 0, 0, 0], -50: [0, 0, 0, 0, 0, 0, 0, 2, 0]})


Any help would be great !



asked 1 min ago







Update value from one default dictionary with another in python 3.x

Aucun commentaire:

Enregistrer un commentaire