0 votes
in Python by
Write Python code to check the given sequence is a palindrome or not?

1 Answer

0 votes
by
1

2

3

4

5

6

7

8

9

10

11

# Python code to check a given sequence

#  is palindrome or not

my_string1 = 'MOM'

My_string1 = my_string1.casefold()

# reverse the given string

rev_string1  = reversed(my_string1)

# check whether the string is equal to the reverse of it or not

if list(my_string1) == list(rev_string1):

print("It is a palindrome")

else:

print("It is not a palindrome")

Python Certification Training!

Explore Curriculum

Output:

1

it is a palindrome

Related questions

0 votes
asked Oct 14, 2021 in Python by rajeshsharma
0 votes
asked Jan 10, 2021 in Python by rajeshsharma
...