Skip to content

Commit da848dc

Browse files
authored
Create is_Palindrome.py
Added source code in python
1 parent 4bd9377 commit da848dc

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Recursion/is_Palindrome.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'''A recursive Python program to check whether a string is palindrome or not'''
2+
3+
def isPalindrome(s, i):
4+
if(i > len(s)/2): #base case
5+
return True
6+
ans = False
7+
if((s[i] is s[len(s) - i - 1]) and isPalindrome(s, i + 1)): #recursive step
8+
ans = True
9+
return ans
10+
11+
str = "racecar"
12+
if (isPalindrome(str, 0)):
13+
print("Yes")
14+
else:
15+
print("No")
16+

0 commit comments

Comments
 (0)