每日练习③:duplicate_count

'''
def duplicate_count():
    #写代码,要求实现以下功能给你一串字符串你要返回他的有重复的的字母个数包括大小

    # test.assert_equals(duplicate_count("abcde"), 0)
    # test.assert_equals(duplicate_count("abcdea"), 1)
    # test.assert_equals(duplicate_count("indivisibility"), 1)
'''
def duplicate_count(text):
    dicts = {}
    text = text.lower()
    for i in text:
        if text.count(i) > 1:
            dicts[i] = text.count(i)
    return dicts

a=duplicate_count('heLLLLLlo world')
print(a)
原文地址:https://www.cnblogs.com/q1ang/p/9348521.html