Palindrome String Checker using Python
Topic: Palindrome String Checker using Python.
Hey Guys, today we are going see a Python Program to check whether a string is Palindrome or not.
Title: Python Code for Palindrome String Checker with user input. (Beginner Friendly + Easy + Code + Output + Online Compiler)
What is this program and why we are going to use it?
This Program consists of Variables, Input Function, Loop / String Slicing and Conditional Statements (if-else).
By using variables, we store string input from the user. By using input function, we take input from the user. For example:
s = "madam"
Here s is a variable where "madam" is assigned to s.
A palindrome string is a string that remains the same when reversed.
By using variables, we store string input from the user. By using input function, we take input from the user. For example:
s = "madam"
Here s is a variable where "madam" is assigned to s.
A palindrome string is a string that remains the same when reversed.
s = input("Enter a string: ")
So, this will ask user to input a string.
Logic:
1. Take a string (s) from user.
2. Reverse the string using slicing (s[::-1]).
3. Compare original string with reversed string.
4. If both are equal → Palindrome.
5. Else → Not Palindrome.
Code:
Online Compiler (Switch to Interactive Mode before execution):
Example Output:
Input: madam
Output: Palindrome
Input: hello
Output: Not Palindrome
Output: Palindrome
Input: hello
Output: Not Palindrome
Applications:
1. Used in string validation problems
2. Helps in understanding string manipulation
3. Useful in algorithms and interview questions
2. Helps in understanding string manipulation
3. Useful in algorithms and interview questions
Comments
Post a Comment