Write a function that will return the count of distinct case-insensitive alphabetic characters and numeric digits that occur more than once in the input string. The input string can be assumed to contain only alphabets (both uppercase and lowercase) and numeric digits.
编写一个函数,计算出一个字符串里面有几种字母重复,不区分大小写:
源码:
def duplicate_count(text):
count = 0
cdic = {}
ntext = text.lower()
for i in ntext:
cdic.setdefault(i,0)
cdic[i] += 1
for k,v in cdic.items():
if v>1:
count += 1
return count