{"id":6927,"date":"2023-10-31T08:16:01","date_gmt":"2023-10-31T02:46:01","guid":{"rendered":"https:\/\/python-programs.com\/?p=6927"},"modified":"2023-11-10T12:08:42","modified_gmt":"2023-11-10T06:38:42","slug":"python-program-to-check-if-a-string-is-palindrome-or-not","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-check-if-a-string-is-palindrome-or-not\/","title":{"rendered":"Python program to check if a string is palindrome or not"},"content":{"rendered":"

Palindrome:<\/strong><\/p>\n

If a number reads the same both forward and backward, it is called a Palindrome number. And the insane part is that it doesn’t just apply to numbers. Even if a string reads the same in both directions, it is always a Palindrome!<\/p>\n

Examples for string palindrome<\/strong><\/p>\n

Example 1:<\/strong><\/p>\n

Input:\u00a0<\/strong><\/p>\n

given_string = madam<\/pre>\n

Output:<\/strong><\/p>\n

The given string madam is palindrome<\/pre>\n

Explanation:<\/strong><\/p>\n

Here the madam word reads same from front and end so it is palindrome<\/pre>\n

Example 2:<\/strong><\/p>\n

Input:\u00a0<\/strong><\/p>\n

given_string = vicky<\/pre>\n

Output:<\/strong><\/p>\n

The given string vicky is not palindrome<\/pre>\n

Explanation:<\/strong><\/p>\n

Here vicky and ykciv are not equal so it is not a palindrome<\/pre>\n

Examples for number palindrome<\/strong><\/p>\n

Example 1:<\/strong><\/p>\n

Input:\u00a0<\/strong><\/p>\n

given_number =12321<\/pre>\n

Output:<\/strong><\/p>\n

The given number 12321 is palindrome<\/pre>\n

Explanation:<\/strong><\/p>\n

Here the number 12321  reads same from front and end so it is palindrome<\/pre>\n

Example 2:<\/strong><\/p>\n

Input:\u00a0<\/strong><\/p>\n

given_number =12345<\/pre>\n

Output:<\/strong><\/p>\n

The given number 12345 is not palindrome<\/pre>\n

Explanation:<\/strong><\/p>\n

Here 12345 and 54321 are not equal so it is not a palindrome<\/pre>\n

Checking Palindrome in Python<\/h2>\n

There are several ways to check whether the given number is palindrome or not some of them are:<\/p>\n