xxxxxxxxxx
1
person.update({"Profession": "Doctor"})
Copied!
xxxxxxxxxx
d = {1: "one", 2: "three"}
d1 = {2: "two"}
# updates the value of key 2
d.update(d1)
d1 = {3: "three"}
# adds element with key 3
d.update(d1)
# {1: 'one', 2: 'two', 3: 'three'}
xxxxxxxxxx
dict1 = {'color': 'blue', 'shape': 'circle'}
dict2 = {'color': 'red', 'number': 42}
dict1.update(dict2)
# dict1 is now {'color': 'red', 'shape': 'circle', 'number': 42}
xxxxxxxxxx
for project in projects:
project['complete'] = project['id'] in (complete['id'] for complete in completes)
xxxxxxxxxx
d = {1: "one", 2: "three"}
d1 = {2: "two"}
# updates the value of key 2
d.update(d1)
print(d)
d1 = {3: "three"}
# adds element with key 3
d.update(d1)
print(d)