I am trying to prepare for a repetitive interview question. Given an array, find the pairs to get their sum as k. I am using python dictionary in this case instead of sorting method. The code is as follows:

```
def sumToK(lst):
  k = 16  # <- define the k here
  d = {} # build a dictionary 

  # build the hashmap key = val of lst, value = i
  for index, val in enumerate(lst):
    d[val] = index

# find the key; if a key is in the dict, and not the same index as the current key
for i, val in enumerate(lst):
  if (k-val) in d and d[k-val] != i:
    print k-val, val

a = [1,4,45,6,10,12,3]
sumToK(a)

```

I am getting duplicate values in the above way. How can I avoid it? Also, what if the array contains duplicate values. For example a = [1,4,45,6,10,12,4,8,8] Thanks.