Details
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.
Example
"Dermatoglyphics" = true
"moose" = false
"aba" = false
Solutions
mine
def is_isogram(string):
if string:
for index in range(len(string)):
index_two = index + 1
while index != len(string) - 1:
if string[index].lower() == string[index_two].lower():
return False
elif index_two <= len(string) - 2:
index_two += 1
continue
break
return True
Best:
def is_isogram(string):
return len(string) == len(set(string.lower()))
标签:index,lower,string,two,len,Isograms,isogram From: https://www.cnblogs.com/artwalker/p/17353489.htmlset()函数是Python的内置函数之一,用于创建一个无序不重复元素集