美文网首页
CodeWars打卡(04)

CodeWars打卡(04)

作者: 影醉阏轩窗 | 来源:发表于2018-07-01 00:44 被阅读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级

相关文章

网友评论

      本文标题:CodeWars打卡(04)

      本文链接:https://www.haomeiwen.com/subject/wwnxuftx.html