We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 78f5532 commit e95208fCopy full SHA for e95208f
1 file changed
Codewars/IsIsogram
@@ -0,0 +1,28 @@
1
+# An isogram is a word that has no repeating letters, consecutive or non-consecutive.
2
+# Implement a function that determines whether a string that contains only letters is an isogram.
3
+# Assume the empty string is an isogram. Ignore letter case.
4
+
5
6
+# isIsogram( "Dermatoglyphics" ) == true
7
+# isIsogram( "aba" ) == false
8
+# isIsogram( "moOse" ) == false // -- ignore letter case
9
10
11
+# My solution
12
13
+def is_isogram(string):
14
+ if not string:
15
+ return True
16
+ else:
17
+ text = string.lower()
18
+ for i in text:
19
+ count = text.count(i, 0, len(text)+1)
20
+ if count > 1 :
21
+ return False
22
23
24
25
+ # Best solutions
26
27
+ def is_isogram(string):
28
+ return len(string) == len(set(string.lower()))
0 commit comments