方法一:
def duplicated_count(text):
result=[]
text=text.lower()
for i in text:
if text.count(i) > 1 and i not in result:
result.append(i)
return len(result)
调用函数:
duplicated_count('I love you very much!')
返回:
方法二:
def dup_counts(s):
return len([c for c in set(s.lower()) if s.lower().count(c)>1])
调用函数:
dup_counts('I Love you very much!')
返回: