In this python dictionary program, we will move items from one dictionary to another dictionary.
Steps to solve the program
- Take one dictionary as input and create another empty dictionary.
- Use for loop to iterate over input dictionary.
- Add values from the input dictionary to the empty dictionary.
- Print the output.
D1 = {'name':'john','city':'Landon','country':'UK'}
D2 = {}
for val in D1:
D2[val] = D1[val]
print(D2)
Output :
{'name': 'john', 'city': 'Landon', 'country': 'UK'}