In: Computer Science
2.
Palindromes
A palindrome is a word that reads the same forwards
and backwards. For example,
\aibohphobia" (the irrational fear of palindromes) is
a word that reads the same
forwards and backwards. Write a function
called
isPalindrome()
that accepts a
string as a parameter and returns True if the string
is a palindrome, False otherwise.
Using the function you created, write a
program
Python home work
Python
def isPalindrome(str): #function definition
for i in range(0, int(len(str)/2)): # Run loop from 0 to
len/2
if str[i] != str[len(str)-i-1]: #checking whether characters are
equal or not
return 0
return 1
s = raw_input("Enter the string: ") #taking input as a string
check = isPalindrome(s) #function calling
if (check):
print("True")
else:
print("False")
The above picture is about python program to check whether given string is palindrome or not by using function