logo CodeStepByStep logo

is_1_to_1

Language/Type: Python Collections dict

Write a function named is_1_to_1 that accepts a dictionary whose keys and values are strings as its parameter and returns True if no two keys map to the same value. For example, for the following dictionary your function should return False because both "Hawking" and "Newton" map to the same value:

{"Marty": "206-9024", "Hawking": "123-4567",
 "Smith": "949-0504", "Newton": "123-4567"}

But for the following dictionary your function should return True because each key maps to a unique value:

{"Marty": "206-9024", "Hawking": "555-1234",
 "Smith": "949-0504", "Newton": "123-4567"}

The empty dictionary is considered 1-to-1 and returns True.

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.