CodeWars打卡(04)
2018-07-01 本文已影响0人
影醉阏轩窗
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.
is_isogram("Dermatoglyphics" ) == true
is_isogram("aba" ) == false
is_isogram("moOse" ) == false # -- ignore letter case
我自己的代码如下:
def is_isogram(string):
string = string.lower()
return True if len(string) == len(set(string)) else False
第一名代码:
def is_isogram(string):
return len(string) == len(set(string.lower()))
- 总结:这题比较简单,自己写的代码和第一名代码完全一样,后面的答案就有点鸡肋.
- 高兴一下,codewars代码段位升了一级达到:7级了