-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathISOGRAM
More file actions
27 lines (22 loc) · 815 Bytes
/
ISOGRAM
File metadata and controls
27 lines (22 loc) · 815 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
An isogram is a word that has no repeating letters, consecutive or non-consecutive. Implement a function that determines whether a string that contains only letters is an isogram. Assume the empty string is an isogram. Ignore letter case.
is_isogram("Dermatoglyphics" ) == true
is_isogram("aba" ) == false
is_isogram("moOse" ) == false # -- ignore letter case
SOLUTION :
IN PYTHON :
def is_isogram(string) :
if string == '' :
return(True)
list = []
list.extend(string.lower())
for i in range(len(list)) :
repeatation = list.count(list[i])
global repeat_count
repeat_count = 0
if repeatation > 1 :
repeat_count += 1
return(False)
break
if repeat_count == 0 :
return(True)
print(is_isogram('isogram'))