#common_elements my_dict = {"A" : "K", "B" : "D", "C" : "A", "D" : "Z"} def common_elements(my_dict): for key,value in my_dict.items(): if my_dict.keys() == my_dict.values(): print[key] common_elements(my_dict)