Write a program to check if a word is a Palindrome. A Palindrome is a word or phrase that is the same forwards and backwards, such as kook, madam, nurses run, or radar. You will ask the user for a word or phrase, then you will call a function called checkInput to see if it is a palindrome. You will then output the result. This program should have 1 function:
checkInput: This functions takes in one string parameter (phrase) and uses logic to check if it is a palindrome or not. It should return true or false. Note that Python slicing can be used. For example, if word="Chesterton", then word[0]="C", word[1]="h", etc. NOTE: You MUST use a for or while loop! (You can NOT use this style: if word == word[::-1]:
Name the program palindrome.py

Example output:
Enter a word or phrase: nurses run
nurses run is a palindrome

Press enter to exit
Enter a word or phrase: snow
snow is not a palindrome

Press enter to exit

(Write Code In PYTHON)

Respuesta :

The program is an illustration of loops

What is a palindrome?

A palindrome is a string or number that remains the same when reversed.

The palindrome program

The palindrome program in Python, where comments are used to explain each line is as follows:

#This prompts the user for input

word = input("Enter a word or phrase: ")

#The following is repeated until the user enters "enter"

while word.lower() != "enter":

   #This removes the spaces in the word

   word2 = word.strip()

   #The following loop checks if the string is a palindrome

   for i in range(len(word2)):

       if word2[i]!=word2[-1-i]:

           print(word,'is not a palindrome')

           break

       else:

           print(word,'is a palindrome')

           break

   #This prompts the user for another input

   word = input("Press enter to exit\nEnter a word or phrase: ")

Read more about similar programs at:

https://brainly.com/question/251701