xxxxxxxxxx
a=input('enter a string :')# palindrome in string
b=a[::-1]
if a==b:
print(a,'is a palindrome')
else:
print(a,'is not a palindrome')
print('a is not equal to b')
if a!=b:
print(b, 'the reverse of', a)
#output:
--------------------------------------------------------------------------------
case-I
# not palindrome
enter a string :1254
1254 is not a palindrome
a is not equal to b
4521 the reverse of 1254
--------------------------------------------------------------------------------
case-II
# palindrme
enter a string :12321
12321 is a palindrome
xxxxxxxxxx
s = input('enter string: ')
def palindrome(string):
x = ""
for i in string:
x = i + x
return x
if s == palindrome(s):
print('its a palindrome')
else:
print('its not a palindrome')
xxxxxxxxxx
s = "001100"
if s == s[::-1]:
print("palindrome string")
else:
print("Not a palindrome string.")
xxxxxxxxxx
num=int(input("Enter a no.:"))
rev=0
num1=num
while num!=0:
rev=rev*10+(num%10)
num=num//10
if num1==rev:
print(num1," is a palindrome")
else:
print(num1," is not a palindrome")
xxxxxxxxxx
n = input("Enter the word and see if it is palindrome: ") #check palindrome
if n == n[::-1]:
print("This word is palindrome")
else:
print("This word is not palindrome")
print("franco")
xxxxxxxxxx
string = input("Type a string: ")
if string[::-1] == string:
print(string,"This string is Palindrome")
else:
print(string,"This string is not Palindrome")
xxxxxxxxxx
def isPalindrome(s):
return s == s[::-1]
# Driver code
s = "malayalam"
ans = isPalindrome(s)
if ans:
print("Yes")
else:
print("No")
xxxxxxxxxx
s = "001100"
if s == s[::-1]:
print(s, "is a Palindrome string.")
else:
print("Not a palindrome string.")
xxxxxxxxxx
is_palindrome = lambda phrase: phrase == phrase[::-1]
print(is_palindrome('anna')) # True
print(is_palindrome('rats live on no evil star')) # True
print(is_palindrome('kdljfasjf')) # False