I have a dictionary which consists of unique key value pairs as follows:

```
    edu_bg={1: 1, 2: 2, 3: 1, 4: 1, 5: 2, 6: 2}

```

I want to create a dictionary from above data so that similar records (which has similar values) are grouped together as follows:

```
   {(1, 3): 1, (5, 6): 1, (1, 4): 1, (2, 6): 1,(2, 5): 1, (3, 4): 1})

```

I tried to achieve above output using following code:

```
    myedu = defaultdict(int)
    for k,v in edu_bg.iteritems():
        for K,V in edu_bg.iteritems():
          if K == k and V == v:
              pass
          if K != k and V == v:
              myedu[(k,K)] += 1
          else:
              pass

```

However it has resulted in duplicate records as follows:

```
         defaultdict(<type 'int'>, {(1, 3): 1, (5, 6): 1, (4, 1): 1, (3, 1): 1, (5, 2): 1, (1, 4): 1, (2, 6): 1, (4, 3): 1, (6, 2): 1, (2, 5): 1, (3, 4): 1, (6, 5): 1})

```

I want to remove these duplicate values. Any advice on this problem is appreciated.