check if there are duplicates in string python code example
Example 1: python check for duplicate
def checkDuplicate(user):
if len(set(user)) < len(user):
return True
return False
Example 2: python find duplicates in string
from collections import Counter
def do_find_duplicates(x):
x =input("Enter a word = ")
for key,val in Counter(x).items():
print(key,val)