list - Append a dictionary in Python -


how can append dictionary following in python?

list1 = {'value1':1} list2 = {'value2':2}  list1.append(list2) 

when appending:

'dict' object has no attribute 'append' 

how can join both list then?

these dictionaries, not lists.

try list1.update(list2)

the semantics of update , append different, because underlying data structures different. values existing keys in dictionary overwritten values in argument dictionary.

the section of python tutorial on data structures goes through , whole lot more.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -