美文网首页
codewar练习--1

codewar练习--1

作者: 伊则吉尔老婆子 | 来源:发表于2017-07-25 16:10 被阅读0次

题目: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

相关文章

  • codewar练习--1

    题目:An isogram is a word that has no repeating letters, co...

  • codewar1

    一道题目:Descending Order。要求给出一个数字,把它自身的数位上的数从大到小排序一遍。涉及数字,字符...

  • CodeWar

    使用isNaN()检查数字的漏洞: .和e有时会无法排除

  • 2019-07-28

    codewar卡塔 Given an array, find the int that appears an od...

  • Java 算法 CodeWar——Day 1

    Code War code war honor 27 uestc position 58 quesetion 1 ...

  • 阶乘,大数,小数位数

    在codewar的一道题 Consider the following numbers (where n! is ...

  • CodeWar::DoubleCola

    CodeWar上的一道题 Sheldon, Leonard, Penny, Rajesh and Howard a...

  • Codewar每日学习

    这是Codewar的习题,我通过它来锻炼编程技巧。 2018/1/4 这里的字符串join方法是给它一个可以迭代的...

  • CodeWar::Sum of Intervals

    Write a function called sumIntervals/sum_intervals() that...

  • Clever Answers in Codewar(Javasc

    problem: clever solution: 2.problem: one line solution:使用...

网友评论

      本文标题:codewar练习--1

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