Ask Question
2 March, 00:13

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

+2
Answers (1)
  1. 2 March, 03:29
    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?
Get 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 there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers