Semaine 4, jour 2
This commit is contained in:
21
Semaine_04/Exercices/coke_kata.py
Normal file
21
Semaine_04/Exercices/coke_kata.py
Normal file
@@ -0,0 +1,21 @@
|
||||
"""
|
||||
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()))
|
||||
Reference in New Issue
Block a user