Python program that accepts a dictionary whose keys and values are strings as a parameter and returns True if no two keys map to the same value.

Write a function is_unique that accepts a dictionary whose keys and values are 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, if the dictionary contains the following key/value pairs, your function would return True:

{‘Marty’: ‘Stepp’, ‘Stuart’: ‘Reges’, ‘Jessica’: ‘Wolk’,

 ‘Allison’: ‘Obourn’, ‘Hal’: ‘Perkins’}

But calling your function on the following dictionary would return False, because of two mappings for Perkins and Reges:

{‘Kendrick’: ‘Perkins’, ‘Stuart’: ‘Reges’, ‘Jessica’: ‘Wolk’,

 ‘Bruce’: ‘Reges’, ‘Hal’: ‘Perkins’}

 

def is_unique(d):
     values = []     for key, value in d.items():
         if (value in values):
             return False
         else:
             values.append(value)
     return True

d = {‘Marty’: ‘Stepp’, ‘Stuart’: ‘Reges’, ‘Jessica’: ‘Wolk’, ‘Allison’: ‘Obourn’, ‘Hal’: ‘Perkins’}
print(is_unique(d))

d = {‘Kendrick’: ‘Perkins’, ‘Stuart’: ‘Reges’, ‘Jessica’: ‘Wolk’, ‘Bruce’: ‘Reges’, ‘Hal’: ‘Perkins’}
print(is_unique(d))

P