Header Ads

ad728
  • Breaking News

    How to check a string is palindrome in python




    input_string = input("Enter a string: ")

    # Remove spaces and convert the string to lowercase
    input_string = input_string.replace(" ", "").lower()

    # Compare the string with its reverse
    if input_string == input_string[::-1]:
        print("The string is a palindrome.")
    else:
        print("The string is not a palindrome.")

    No comments