1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
postnew [5]
3 years ago
9

Write a program that prompts the user for a word or phrase, and determines if the entry is a palindrome. A palindrome is a word

or phrase which reads the same forwards and backwards. For example, if the user entered: madam the program should display: That is a palindrome Your program should ignore spaces, commas, and apostrophes, and ignore differences between upper and lower case. For example, the phrase: Madam, I'm Adam would be considered a palindrome.
Computers and Technology
1 answer:
vekshin13 years ago
7 0

Answer:

Explanation:

The following code is written in Python. It asks the user for an input. Then cleans the input using regex to remove all commas, whitespace, and apostrophes as well as making it all lowercase. Then it reverses the phrase and saves it to a variable called reverse. Finally, it compares the two versions of the phrase, if they are equal it prints out that it is a palindrome, otherwise it prints that it is not a palindrome. The test case output can be seen in the attached picture below.

import re

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

phrase = re.sub("[,'\s]", '', phrase).lower()

reverse = phrase[::-1]

if phrase == reverse:

   print("This word/phrase is a palindrome")

else:

   print("This word/phrase is NOT a palindrome")

You might be interested in
A common type of non-volatile memory is _____.
lilavasa [31]
SD? RAM? What are you getting at here????
7 0
3 years ago
When using a software budget, you should feel very confident if you choose a solution that looks like it will come in exactly on
ludmilkaskok [199]

Answer:

probably false

Explanation:

because u dont want a budget to b exact u want it completely covered

3 0
3 years ago
Which of these is a benefit of using the Sort option?​
Reika [66]

There are many benefits of using the shot options in Excel. Some benefits are allowing you to short by number,date,color, letter, columns,or text. This benefits the user because it allows the user to bring data up more easily.

I hope this answers is helpful

3 0
3 years ago
Write an Email of your Friend Asking Him Help i​
lyudmila [28]

Answer:

Explanation:

7

3 0
3 years ago
Read 2 more answers
Which best describes the possible careers based on
Kisachek [45]

Answer:

It's c bodie I'm fr on this question rn lol

6 0
3 years ago
Read 2 more answers
Other questions:
  • There is no reason to study the works of famous photographers because they will make you less creative.
    5·2 answers
  • . char values are surrounded by _____ quotes
    15·1 answer
  • Darian has a gourmet cupcake business and needs a website to compete with the other bakeries in his area. He has a Google My Bus
    15·1 answer
  • Network Industries, Inc., wants to monitor its employees’ electronic com-munications. To avoid liability under laws related to e
    12·1 answer
  • A network technician is designing a network for a small company. The network technician needs to implement an email server and w
    7·1 answer
  • You CANNOT add text to any filled shape.<br> O True<br> False
    8·1 answer
  • Write a method, public static void selectSort(ArrayList list), which implements a selection sort on the ArrayList of Integer obj
    10·1 answer
  • Helen is working on her colleague’s photos. She came across this particular photo and was confused about which effect the photog
    15·2 answers
  • Name the three major functions performed by the computer.
    6·1 answer
  • Select the correct answer.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!