1n = input("Enter the word and see if it is palindrome: ") #check palindrome
2if n == n[::-1]:
3 print("This word is palindrome")
4else:
5 print("This word is not palindrome")
1s=input("enter:")
2temp=s
3c=0
4v=0
5print(temp)
6for i in s:
7 c=c+1
8for j in range(c):
9 if temp[v]==s[c-1]:
10 c=c-1
11 v=v+1
12 flag=1
13 else:
14 flag=0
15if flag==1:
16 print("p")
17elif flag==0:
18 print("no")
19
1value = input("Enter a Word: ")
2
3if value == value[::-1] :
4 print(value)
5 print(value[::-1])
6 print("THIS WORD IS A PALINDROME")
7else :
8 print(value)
9 print(value[::-1])
10 print("THIS WORD IS NOT A PALINDROME")
1def palindrome_check(string):
2 string = list(string)
3 tmp = []
4 #remove any spaces
5 for x in range(0, len(string)):
6 if(string[x] != " "):
7 tmp.append(string[x].lower())
8
9
10 #now reverse the string
11 array1 = []
12 i = 0
13 j = len(tmp)-1
14
15 while(i < len(tmp)):
16 array1.append(tmp[j])
17 i += 1
18 j -= 1
19
20 #check if array1 is equal to the string
21 counter = 0
22 for x in range(0, len(tmp)):
23 if(tmp[x] == array1[x]):
24 counter += 1
25
26 #if the counter is equal to the length of the string then the word
27 #is the same
28 if(counter == len(tmp)):
29 return True
30
31 return False
1#A palindrome is a word, number, phrase, or other sequence of characters which reads the same backward as forward.
2#Ex: madam or racecar.
3def is_palindrome(w):
4 if w==w[::-1]: # w[::-1] it will reverse the given string value.
5 print("Given String is palindrome")
6 else:
7 print("Given String is not palindrome")
8
9is_palindrome("racecar")