Question: Write 3 functions in the starter code below such that . add to-dictl): takes a dictionary, a key, a value and adds the key,value pair

 Write 3 functions in the starter code below such that .add to-dictl): takes a dictionary, a key, a value and adds the

Write 3 functions in the starter code below such that . add to-dictl): takes a dictionary, a key, a value and adds the key,value pair to the dictionary. If key is already in dictionary then it displays the eror message: 'Error. Key already exists. ? remove-from-dict takes a dictionary and key and removes the key from the dictionary. Returns dictionary. If no such key is found in the dictionary then it prints: "No such key exists in the . find_keyldictt, key): takes dictionary and key and prints value corresponding to the key from the dictionary: printlValue:", value). If key is not found, then prints: Key not found. Hint: Use Retums dictionary dictionary.. Hint: Use try-except try-except Example: Menu: add(a), remove), findl: a Key: rich Value: I More (y)? y add(a), removefr), find(f]: a Key: alireza Value: 2 More (y)? n [[alireza, 2), [rich, T]l Example 2 Menu: add(a], removerl, findlrl: a Key: pranshu Value: 1 More [v)? y Menu add(a), removefr), find(f: r key to remove: enbody No such key exists in the dictionary More [v)? n

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!