find duplicate letters in python code example
Example 1: python find first duplicate numbers
def findDuplicateNumbers(a):
mySet = set()
for el in a:
if el in mySet:
return el
mySet.add(el)
return -1
Example 2: check for double character in a string python
count = {}
for s in check_string:
if s in count:
count[s] += 1
else:
count[s] = 1
for key in count:
if count[key] > 1:
print key, count[key]