I am used to the verbosity of Java. So Python is like a breath of fresh air. But this Python code stumped me for the better part of two days.

I was trying to filter the keys in the dictionary shown above based on its own values. One of the examples is shown in a different color. So if the key matches a value then that dictionary row with that particular key should be removed. The row with the matching value is untouched.

It is literally one line of Python.

for v in friends.iteritems():
print v
result = [k for k, v in friends.iteritems() if v not in friends.keys()]
for v in result:
print v