Skip to content
I want a help with dictionary problem
Profile icon
azza1551

1 - How to write a function that takes a dictionary and a key and determines if that key is in the dictionary (i.e. the function outputs True if the key is in the dictionary, and False otherwise). This should output: True and False

2 - How to write a function that takes two dictionaries with unique keys and merge them.
This should output: {'Ten': 10, 'Twenty': 20, 'Thirty': 30, 'Fourty': 40, 'Fifty': 50}

You are viewing a single comment. View All
Profile icon
CosmicBear
def function1(dict,key): if key in dict: return True return False def function2(dict1,dict2): for key in dict2: dict1[key] = dict2[key] return dict1