Javatpoint Logo
Javatpoint Logo

Palindrome program in python language

What is a palindrome?

A palindrome is a number or letter that remains the same even if the number and letters are inverted.

For example:

121, 11, 414, 1221, 74747 are the palindrome numbers.

MOM, DAD, MADAM, REFER are the palindrome letters.

JAVATPOINT, PROGRAM, JAVA are not the palindrome letters.

Palindrome algorithm

  • Read the number or letter.
  • Hold the letter or number in a temporary variable.
  • Reverse the letter or number.
  • Compare the temporary variable with reverses letter or number.
  • If both letters or numbers are the same, print "this string/number is a palindrome."
  • Else print, "this string/number is not a palindrome."

Palindrome Program

Program 1: Palindrome string



Program 2: Palindrome string program


Enter a letter: javatpoint
The letter is not a palindrome

Enter a letter: MADAM
The letter is a palindrome

Program 3: Palindrome number program using while loop


Enter the value: 2551
This value is not a palindrome number!

Enter the value: 1221
This value is a palindrome number!

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA