Question: Write a function uniqueValues () that takes a dictionary as a parameter and returns a set of the unique values in the dictionary. If the

  1. Write a function uniqueValues() that takes a dictionary as a parameter and returns a set of the unique values in the dictionary. If the dictionary is empty, the function returns the empty set. If any of the values in the dictionary are strings, capitalization of the strings matters when forming the set returned so that a string that differs by capitalization only would appear twice in the returned set. If any of the values in the dictionary cannot be added to a set, then those values are skipped. The function should not modify the dictionary passed as a parameter. Hint: Use exception handling for this process. Below you can see several sample runs of the function. Your function must work as described on any dictionary, not just the examples presented below:

P.S. Use an accumulator loop. It will run through the values in the dictionary and attempt to add each value to a set. There should be exception handling to deal with the situation when a value cannot be added to the set without an error. The set you build should be returned when all values have been considered, e.g. outside the accumulator loop.

Python 3.7.2 Shell File Edit She Debug Options Window Help 48, 50, 14) >>> type (s) >>> s uniqueValues (('Mick': 'cookie, 'Mike': 'cookie', Megan': 'Sweet Tarts = David': 'chocolate', Amber' CHOCOLATE')) f 'cookie', 'Sweet Tarts',CHOCOLATE,chocolate' >>> 3 - unicqueValues(f>) set ( >>> s = uniqueValues (('Amber': [50, 1968j, Erin': [14, 2004])) set ( >>> s = uniqueValues (('Amber': [50, 1968], 'Erin': [14, 2004], 'Gertrude': 2007, Prudence 2007) (2007) Ln: 22 Col: 4

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!