user_info = {
"name": "John",
"email": "test@test.com"
}
address_info = {
"city": "New York",
"country": "USA"
}
#Merge using .update() method
user_info.update(address_info)
print(user_info);
#Merge using ** operator
merged = {**user_info, **address_info}
print(merged)
Output
{'name': 'John', 'email': 'test@test.com', 'city': 'New York', 'country': 'USA'}
{'name': 'John', 'email': 'test@test.com', 'city': 'New York', 'country': 'USA'}
0 Comments