Skip to content

Commit 2ed89e5

Browse files
committed
count chars
1 parent f57b01b commit 2ed89e5

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

dupl_count.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Learn Python together
2+
3+
"""Write a function that will return the count of distinct
4+
case-insensitive alphabetic charactersand numeric digits
5+
that occur more than once in the input string."""
6+
7+
# Solution
8+
9+
def duplicate_count(text):
10+
# convert text to lowecase
11+
text = text.lower()
12+
13+
# using a set comprehesion to get a set of chars
14+
duplicates = {char for char in text if text.count(char) > 1}
15+
16+
return len(duplicates)
17+
18+
# check
19+
20+
print(duplicate_count('Abcdaa'))
21+
print(duplicate_count('PythonnnssDD!!'))

0 commit comments

Comments
 (0)