Files
2026-01-14 10:21:12 +01:00

22 lines
617 B
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):
string = string.lower()
for letter in string:
if string.count(letter) > 1:
return False
return True
# Solution la plus opti
def is_isogram(string):
return len(string) == len(set(string.lower()))