We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f57b01b commit 2ed89e5Copy full SHA for 2ed89e5
1 file changed
dupl_count.py
@@ -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