Python
>>> x = {"USA":3,"India":11,"Brazil":1} >>> x
{'Brazil':1,'India':11,'USA':3}
>>> x = {2:3,"India":11,"Brazil":[1,2,3]} >>> x
{2: 3, 'Brazil': [1,2,3],'India': 11}Add items to dictionary:
>>> x[12] = "aa" >>> x
{2: 3, 12: 'aa', 'Brazil': [1,2,3],'India': 11}Delete items of dictionary:
>>> del x[2] >>> x
{12: 'aa', 'Brazil': [1,2,3],'India': 11}
>>> x.clear()#remove all entries in x >>> del xdelete x
Update dictionary item value:
>>> x = {12: 'aa', 'Brazil': [1,2,3],'India': 11} >>> x[12] = "bb"#update x[12] value >>> x
{12: 'bb', 'Brazil': [1,2,3], 'Inida': 11}Loop through dictionary:
>>> x = {"USA":3,"India":11,"Brazil":1} >>> for i in x: >>> print(i,x[i])
Brazil 1 USA 3 India 11