KnowledgeBoat Logo
|
LoginJOIN NOW

Computer Science

Write a Python script to merge two Python dictionaries.

Python

Python Dictionaries

3 Likes

Answer

dict1 = eval(input("Enter the first dictionary: "))
dict2 = eval(input("Enter the second dictionary: "))
dict1.update(dict2)
print("Merged dictionary:", dict1)

Output

Enter the first dictionary: {1 : "Orange", 2: "Mango", 3 : "Watermelon"}
Enter the second dictionary: {4 : "Pineapple", 5 : "Banana"}
Merged dictionary: {1: 'Orange', 2: 'Mango', 3: 'Watermelon', 4: 'Pineapple', 5: 'Banana'}

Answered By

1 Like


Related Questions