Posts

Showing posts with the label Palindrome

Python program to check whether the inputted string is a Palindrome or not - Codicaly

Image
  In this post, we are going to check whether an inputted string is a Palindrome or not. What is Palindrome ?               A Palindrome  is a word, number, phrase, or other sequence of characters that reads the same backward as forward, such as madam or racecar. That means if the reverse of the inputted string is the same as that of the original, it is Palindrome otherwise not. Pre-requisites : Python Basics Strings concept Conditional statements. Program : a=input('Enter the phrase : ') reverse=a[::-1] if (reverse==a):     print(a,'is a pallindrome') else:     print(a,'is not a pallindrome') Explanation : 1. First we need to input the word for which we need to check it is a Palindrome or not. Using the input function we are inputting the phrase. Here we are not specifying anything before input like int or float. Hence it would take as a string that is the default. 2. To check we need to compare the reverse of the phr...