is_isogram("Dermatoglyphics" ) == true
is_isogram("aba" ) == false
is_isogram("moOse" ) == false # -- ignore letter case
#codewars第二题
def is_isogram(string):
#your code here
if string == "": return True
string = string.upper()
_length = len(string)
for i in range(0,_length):
for j in range(_length-1,i,-1): #小心下标越界 string[j]中的j不可以取到_length
if string[i] == string[j]:
return False
else: continue
if i == _length-1:
return True
else:
return False
#其他解法
def is_isogram(s):
s = s.lower()
return len(s) < 2 or len([x for i, x in enumerate(s) if s.index(x) == i]) == len(s)
is_isogram("")