- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python program to check if a string is palindrome or not
Given a string, our task is to check weather this string is palindrome or not.
Algorithm
Step1: Enter string as an input. Step2: Using string slicing we reverse the string and compare it back to the original string. Step3: Then display the result.
Example code
my_string=input("Enter string:") if(my_string==my_string[::-1]): print("The string is a palindrome") else: print("The string isn't a palindrome")
Output
Enter string:madam The string is a palindrome Enter string:python The string isn't a palindrome
Advertisements