

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to Check Whether a String is Palindrome or Not using Python?
Use reveresed() function from Python's standard library. It returns reversed object which can be converted in a list object
>>> str1='malayalam' >>> l1=list(reversed(str1)) >>> l1 ['m', 'a', 'l', 'a', 'y', 'a', 'l', 'a', 'm']
Join all characters in a list using join() method
>>> str2=''.join(str(x) for x in l1)
Compare str1 and str2. If they are equal the original string is a palindrome
>>> if str1==str2: print ('palindrome') else: print ('not palindrome')
- Related Questions & Answers
- Python Program to Check Whether a String is a Palindrome or not Using Recursion
- Python program to check if a string is palindrome or not
- Program to check a string is palindrome or not in Python
- C++ Program to Check Whether a Number is Palindrome or Not
- Python program to check whether the string is Symmetrical or Palindrome
- How to check whether a number is prime or not using Python?
- Check whether a string is valid JSON or not in Python
- Python program to check whether a given string is Heterogram or not
- C# program to check if a string is palindrome or not
- Program to check whether inorder sequence of a tree is palindrome or not in Python
- Check if any anagram of a string is palindrome or not in Python
- Write a Golang program to check whether a given number is a palindrome or not
- Program to check string is palindrome or not with equivalent pairs in Python
- Program to check string is palindrome with lowercase characters or not in Python
- How to check whether a String contains a substring or not?
Advertisements