I need to write a function that determines if a given string is a palindrome. Here is what I wrote so far:
def isPalindrome(string):
found = False
for i in range(len(string)):
if string[i] == string[len(string) - 1 - i]:
found = True
if found == True:
print("Inserted string is a palindrome. ")
else:
print("Inserted string is not a palindrome. ")
return
I iterate over the string, and check if forward and backward iteration gives equal characters. But if I apply this program by executing isPalindrome("hello") , it says this is a palindrome. It doesn't give me the correct output. Could someone please point out any mistake I made, so that I may learn from that.