So I have this code for detecting if a string is a palindrome (the same forward and backwards) and I'm not sure how to change it to a recursive program
def isPalindrome(string):
i = 0
j = len(string) - 1
k = 0
while (i <= j):
if string[j] != string[i]:
k = 1
else:
i += 1
j -= 1
if k == 0:
return True
else:
return False
def main():
print("This program tests if strings are palindromes.")
word = input("Enter a string: ")
while word != "quit" :
if isPalindrome(word) == True:
print(word,"is a palindrome.")
else:
print(word,"is not a palindrome.")
word = input("Enter a string: ")
main()
I'm really bad with recursions and I don't really understand them any help would be great. Thanks