xxxxxxxxxx
s = "001100"
if s == s[::-1]:
print(s, "is a Palindrome string.")
else:
print("Not a palindrome string.")
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
myString = "aba"
if myString == myString[::-1]:
print("The string '" + myString + "' is a palindrome")
else:
print("The string '" + myString + "' is not a palindrome")
xxxxxxxxxx
def is_palindrome(s):
reverse = s[::-1]
if (s == reverse):
return True
return False
s1 = 'racecar'
s2 = 'hippopotamus'
print('\'racecar\' a palindrome -> {}'.format(is_palindrome(s1)))
print('\'hippopotamus\' a palindrome -> {}'.format(is_palindrome(s2)))
# output
# 'racecar' is a palindrome -> True
# 'hippopotamus' is a palindrome -> False
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
word = input() if str(word) == str(word)[::-1] : print("Palindrome") else: print("Not Palindrome")
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")