Ask Question

A palindrome is a word or a phrase that is the same when read both forward and backward. Examples are: "bob," "sees," or "never odd or even" (ignoring spaces). Write a program whose input is a word or phrase, and that outputs whether the input is a palindrome.

Ex: If the input is:

bob

the output is:

bob is a palindrome

Ex: If the input is:

bobby

the output is:

bobby is not a palindrome

+3
Answers (1)
  1. 17 May, 14:52
    0
    string = input ()

    normal = ""

    reverse = ""

    for i in range (len (string)):

    if string[i]. isalpha ():

    normal + = string[i]. lower ()

    reverse = string[i]. lower () + reverse

    if normal = = reverse:

    print (string + " is a palindrome")

    else:

    print (string + " is not a palindrome")

    Explanation:

    Loop up to the length of string. Use an if statement to check if a certain character is an alphabet. Check if both the normal and reverse strings are equal, then display that it is a palindrome.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “A palindrome is a word or a phrase that is the same when read both forward and backward. Examples are: "bob," "sees," or "never odd or ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers