Python Program to Check if a Given String is Palindrome

A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward. This program illustrates how to create a Python program to determine whether a given string is a palindrome or not.

Problem Statement

Write a Python program that takes a string as input and checks whether it is a palindrome or not.

Python Program to Check if a Given String is Palindrome

def is_palindrome(string):
    string = string.lower()  # Convert to lowercase for case-insensitive comparison
    reversed_string = string[::-1]
    return string == reversed_string

# Input
input_string = input("Enter a string: ")

# Checking for palindrome
if is_palindrome(input_string):
    print("The given string is a palindrome.")
else:
    print("The given string is not a palindrome.")
      

Input / Output

Python Program to Check if a Given String is Palindrome

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

In this python tutorial, you will learn how to Display Prime Numbers Between Two Intervals using the if and else...
In this python tutorial, you will learn how to Calculate Standard Deviation with built in functions of the python programming...
In this Python program, we will convert temperature values from Celsius to Fahrenheit. The Celsius and Fahrenheit scales are two...