题目: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
def is_isogram(string):
#your code here
string = string.lower()
string_set = set(string)
if len(string) != len(string_set):
return False
else:
for i in string:
if i not in 'abcdefghijklmnopqrstuvwxyz':
return False
return True
网友评论