Answers for "dictionary push in python"

5

python3 add dictionary to dictionary

dict_1 = {"1":"a", "2":"b", "3":"c"}
dict_2 = {"4":"d", "5":"e", "6":"f"}

dict_1.update(dict_2) 
print(dict_1)
#Output = {"1":"a", "2":"b", "3":"c", "4":"d", "5":"e", "6":"f"}
Posted by: Guest on April-23-2020
2

add values to dictionary key python

key = "somekey"
a.setdefault(key, [])
a[key].append(2)
Posted by: Guest on December-30-2020

Python Answers by Framework

Browse Popular Code Answers by Language