Daniel S. answered 07/28/20
Software Engineer and Johns Hopkins Computer Science Grad
Hi Alwin,
Here's how I would do it in Python:
Because you are printing the results of a function call in your example, the function would need to return 'mydict'
Alwin G.
asked 07/26/20#Task 11
# Complete the function to remove a dictionary item if it exists
def removeDictItem(mydict, key):
# expected output: {'tomato': 'red', 'lime': 'green'}
print(removeDictItem({'tomato': 'red', 'banana': 'yellow', 'lime': 'green'} , 'banana'))
# expected output: {'Brazil': 'Brasilia', 'Ireland': 'Dublin', 'Indonesia': 'Jakarta'}
print(removeDictItem({'Brazil': 'Brasilia', 'Ireland': 'Dublin', 'Indonesia': 'Jakarta'},'Cameroon'))
Daniel S. answered 07/28/20
Software Engineer and Johns Hopkins Computer Science Grad
Hi Alwin,
Here's how I would do it in Python:
Because you are printing the results of a function call in your example, the function would need to return 'mydict'
Get a free answer to a quick problem.
Most questions answered within 4 hours.
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.