Tuesday, February 1, 2022

Isograms Codewars Python

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.

Example: (Input --> Output)

"Dermatoglyphics" --> true

"aba" --> false "moOse" --> false (ignore letter case)


def is_isogram(string):
    for i in string.lower():
        if string.lower().count(i) > 1:
            return False
    return True

# If count is greater than 1, return False


Related Posts


No comments :

Post a Comment