Skip to content

Commit d2c83bb

Browse files
palindrome
1 parent 52d62ac commit d2c83bb

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

palindrome

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
def is_palindrome(s):
2+
s = s.lower()
3+
if len(s) <= 1:
4+
return True
5+
if s[0] == s[-1]:
6+
return is_palindrome(s[1:-1])
7+
else:
8+
return False
9+
10+
11+
input_string = "racecar"
12+
if is_palindrome(input_string):
13+
print(f"{input_string} is a palindrome.")
14+
else:
15+
print(f"{input_string} is not a palindrome.")

0 commit comments

Comments
 (0)