37
loading...
This website collects cookies to deliver better user experience
update()
methoda={1:10, 2:20}
b={3:30, 4:40}
c={}
for i in (a,b):
#for every element in dictionary a AND dictionary b,
c.update(i)
#update the dictionary to include these values.
print(c)
{1: 10, 2: 20, 3: 30, 4: 40}
update()
method.a={1:10, 2:20}
b={3:30, 4:40 , 2:60}
c={}
d={}
for i in (a,b):
c.update(i)
print(c)
for i in (b,a):
d.update(i)
print(d)
{1: 10, 2: 60, 3: 30, 4: 40}
{1: 10, 2: 20, 3: 30, 4: 40}
a = {
"a":1,
"b":2,
"c":3,
"e":4
}
# Replace 'e' by 'd'
a["d"] = a.pop("e")
print(a)
{'b': 2, 'a': 1, 'c': 3, 'd': 4}
For those who have not yet made account in Dev.to, you can have a free easy sign-up using your mail or GitHub accounts. I would suggest the budding developers to create your GitHub free account right away. You would require to register sooner or later anyways