Showing posts with label String Palindrome in Python. Show all posts
Showing posts with label String Palindrome in Python. Show all posts

Friday, May 30, 2014

Palindrome of String in Python


One of the most common programming problem that is related to string manipulation is all about Palindrome. In a simple explanation palindrome is a word, string or numbers that when we read it forward and backwards the spelling and the pronunciation is still the same. Common examples of word that are palindrome are as follows ana, radar, ama, boob, civic and hannah. 

In computer programming the word string refers to a list or series of characters. Examples of string is "john", "car","secret",'passwords" and many others in most programming language string is always enclosed with double quotations.This program works very simple it will ask the user to enter a string and then the program will determine whether the string that is being provided by the user is a palindrome or not a palindrome. 

The programming language that I implemented our program is python. It one of the most popular programming language that has a vast application in system, application and web development. I just started learning how to write in python it seems this programming language is easy to use and most of the common task and routine in programming is already built in in the language itself. This is very beneficial on the part of the programmer primarily because the programmer can more focus in solving the problem rather than thinking what kind of code to be used to perform a specific task in a problem.

I my own observation python is somewhat seminar to other programming language that is the C programming language, C++ and Java. The best thing about Python is that majoring of the applications written for Linux operating system is written using Python as its programming language. That's why no wonder the Python and Perl interpreter and compiler is already built in most Linux distribution. 

I hope you will find my palindrome program in Python useful in learning how to write a program using Python as your programming language.

Thank you very much.



This is the screenshot if the given word or string is a palindrome.



This is the screenshot if the given word or string is not a palindrome.


This is the Python built is text editor

Program Listing

# A program to check whether the given string is a palindrome or not 
# Author : Mr. Jake R. Pomperada
# Language : Python
# Date : May 30, 2014

print('\n') 
print('===================')
print('Palindrome Checker')
print('===================')
print('\n')

my_string = input("Kindly enter a string :==> ")

my_string = my_string.casefold()

reverse_string = reversed(my_string)

if list(my_string) == list(reverse_string):
   print('\n')
   print('The string ',my_string,' is Palindrome.')
else:
   print('\n')
   print('The string ',my_string,' is not a Palindrome.')

print('\n')   
print('Thank You Very Much For Using This Program')
print('\n')