About 5,990,000 results
Open links in new tab
  1. Python Program to Check if a String is Palindrome or Not

    Feb 21, 2025 · Explanation: is_palindrome (s, i, j) checks if a string is a palindrome by using two pointers, i (left) and j (right). If i >= j, it returns True as all characters matched. If s [i] != s [j], it returns False due to a mismatch. Otherwise, it recursively checks the inner substring with i + …

  2. Python Programs To Check Whether A String Is Palindrome ... - Python

    Jan 31, 2024 · This article explains how to write Python programs to check whether a string is palindrome or not using methods like for loop, while loop, string slicing, etc with examples.

  3. Python Program to Check If a String is a Palindrome (6 Methods)

    Oct 6, 2021 · In this tutorial, you’ll learn how to use Python to check if a string is a palindrome. You’ll learn six different ways to check if a string is a palindrome, including using string indexing, for loops, the reversed() function.

  4. Python Program to Check Whether a String is Palindrome or Not

    # Program to check if a string is palindrome or not my_str = 'aIbohPhoBiA' # make it suitable for caseless comparison my_str = my_str.casefold() # reverse the string rev_str = reversed(my_str) # check if the string is equal to its reverse if list(my_str) == list(rev_str): print("The string is a palindrome.") else: print("The string is not a ...

  5. python - How would I check if a word or sentence is a palindrome ...

    Nov 15, 2016 · To check sentence palindrome-ness, the algorithm seems to be: Compare new_s to new_s[::-1] case-insensitively. You can do the former by doing: Then the latter by doing: Put the whole thing together with: valid = set(string.ascii_letters) result_s = ''.join([ch for ch in s if ch in valid]) cf_s = result_s.casefold() return cf_s == cf_s[::-1]

  6. Palindrome in Python: How to Check a Number or String is ... - Edureka

    Dec 5, 2024 · To check a Palindrome in Python, the program should check whether a given string is the same when read forwards and backward. Consider the following Python program. First, it asks the user to enter a string and stores it. Then, it checks if the string is same as its reverse.

  7. Python Program For Checking Palindrome (With Code) - Python

    Writing a program to check whether a given input is a palindrome or not can be a fun and interesting coding exercise. We will provide you with a step-by-step guide, along with example code, to help you understand the concept better.

  8. python - How to check if a string is a palindrome ... - Stack Overflow

    I have a code to check whether a word is palindrome or not: if str[index] == str[p]: index = index + 1. p = p-1. print("String is a palindrome") break. else: print("string is not a palindrome")

  9. Learn How to Check for Palindrome in Python with Easy …

    This tutorial will teach you how to check if a string is a palindrome in Python. We will walk through the steps of implementing a palindrome checker using different approaches and provide examples for each.

  10. Python program to check if a string is palindrome or not

    Oct 5, 2019 · Given a string, write a python function to check if it is palindrome or not. A string is said to be palindrome if reverse of the string is same as string. For example, “radar” is palindrome, but “radix” is not palindrome.

  11. Some results have been removed
Refresh