how to add a value to a key in dictionary code example
Example 1: how to add an element in dictionary
thisdict = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
thisdict["color"] = "red"
print(thisdict)
Example 2: add values to dictionary key python
key = "somekey"
a.setdefault(key, [])
a[key].append(2)