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()))
上一篇下一篇

猜你喜欢

热点阅读