+ 5
Dictionary in Python
How can I write the following program: A program that receives two dictionaries and adds the values of two dictionaries whose keys are the same and combines the two dictionaries. Example: A={'1':1 , '2':2 , '3':3} B={'3':3 ,'4':4} Answer={'1':1 ,'2':2 , '3':6 , '4':4}
9 Respuestas
+ 1
for i,j in B.items():
if i in A:
c=A[i]+B[i]
A[i]=c
if i not in A:
A[i]=j
print(A)
+ 6
Abhay thanks a lot
+ 3
#Abhay
for i,j in B.items():
.
.
Correct ?
+ 1
viva
0
hi,
please have a cheatsheet on your desktop.
It is a summary of most common statements, functions and datatypes.
Google helps you to find one.
0
SUN what do you mean?
0
👍