mirror of
https://github.com/Fare-spec/cours.git
synced 2025-12-09 11:30:38 +00:00
add exo monday
This commit is contained in:
12
recursivite/exercice_MJoannic/palindrom.py
Normal file
12
recursivite/exercice_MJoannic/palindrom.py
Normal file
@@ -0,0 +1,12 @@
|
||||
def is_palindrom(word)->bool:
|
||||
word = list(word)
|
||||
if len(word) < 2:
|
||||
return True
|
||||
if word[0] == word[-1]:
|
||||
word.pop(0)
|
||||
word.pop(-1)
|
||||
return is_palindrom(word)
|
||||
else:
|
||||
return False
|
||||
|
||||
print(is_palindrom("do geese see god".replace(' ', '')))
|
||||
Reference in New Issue
Block a user