sa 11 cs chapter 13
7. Write a program that checks if two same values in a dictionary have different keys. That is, for dictionary D1 = { ‘a’ : 10, ‘b 20, ‘c’ : 10], the program should print “2 keys have same values” and for dictionary D2 = { ‘a’ : 10, ‘b’ : 20, ‘c’ : 30) , the program should print “No keys have same values”.
# Code D1 = {‘a’: 10, ‘b’: 20, ‘c’: 10} count = {} val = D1.values() for i in val: if i not in count: count[i] = 0 count[i] += 1 a = False # This is used to check if there is atleast one value which occurs more than once for i in count.values():