Computer Science, asked by Raiyaan9354, 10 months ago

Write code to check a string is palindrome or not? In python

Answers

Answered by SUBASHRAJ
0

Answer:

  • # Program to check if a string is palindrome or not.
  • my_str = 'aIbohPhoBiA'
  • # make it suitable for caseless comparison.
  • my_str = my_str. casefold()
  • # reverse the string.
  • rev_str = reversed(my_str)
  • # check if the string is equal to its reverse.
  • if list(my_str) == list(rev_str):

Explanation:

PLEASE MARK MY ANSWER AS A BRAINLIEST ANSWER... PLEASE

Answered by kumarankur966
0

Answer:

st = 'malayalam'

j = -1

flag = 0

for i in st:

   if i != st[j]:

     j = j - 1

     flag = 1

     break

   j = j - 1

if flag == 1:

   print("NO")

else:

   print("Yes")

Explanation:

This method compares the first and the last element of the string and gives the rest of the substring to a recursive call to itself.

Similar questions