logo CodeStepByStep logo

is_unique

Language/Type: Python Collections Dictionaries

Write a function is_unique that accepts a dict from strings to strings as a parameter and returns True if no two keys map to the same value (and False if any two or more keys do map to the same value). For example, calling your function on the following dictionary would return True:

{Marty=Stepp, Stuart=Reges, Jessica=Miller, Amanda=Camp, Hal=Perkins

Calling it on the following dictionary would return False, because of two mappings for Perkins and Reges:

{Kendrick=Perkins, Stuart=Reges, Jessica=Miller, Bruce=Reges, Hal=Perkins

The empty dictionary is considered to be unique, so your function should return True if passed an empty dictionary.

Function: Write a Python function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.