mirror of
https://github.com/Fare-spec/cours.git
synced 2025-12-11 04:10:39 +00:00
Add university content
This commit is contained in:
13
high-school/recursivite/exercice_MJoannic/palindrom.py
Normal file
13
high-school/recursivite/exercice_MJoannic/palindrom.py
Normal file
@@ -0,0 +1,13 @@
|
||||
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