Hi there, I need help on the following problem: I got part of the answer but for some list of words collection can't come up with the expected solution. Here is te question: ============================================== Create a program, palindrome.py, that has a function that takes one string argument and prints a sentence indicating if the text is a palindrome. The function should consider only the alphanumeric characters in the string, and not depend on capitalization, punctuation, or whitespace.             If your string is a palindrome it should print:                     It's a palindrome!             If it is not a palindrome, it should print:                 It's not a palindrome! ====================================== Here is my code and it correctly outputs the answer for the first two in puts, but not for the last two: def isPalindrome(txt): if txt == txt[::-1]: print("It's a Palindrome!") else: print("It's not a Palindrome!") isPalindrome('anna')                # Output: It's a Palindrome isPalindrome('Hello world')     # Output: It's not a Palindrome! isPalindrome('Ed, I saw Harpo Marx ram Oprah W. aside') and match its output to an expected value.  #Output should be: It's a Palindrome! isPalindrome('Dennis, Nell, Edna, Leon, Nedra, Anita, Rolf, Nora, Alice, Carol, Leo, Jane, Reed, Dena, Dale, Basil, Rae, Penny, Lana, Dave, Denny, Lena, Ida, Bernadette, Ben, Ray, Lila, Nina, Jo, Ira, Mara, Sara, Mario, Jan, ' 'Ina, Lily, Arne, Bette, Dan, Reba, Diane, Lynn, Ed, Eva, Dana, Lynne, Pearl, Isabel, Ada, Ned, Dee, Rena, Joel, Lora, Cecil, Aaron, Flora, Tina, Arden, Noel, and Ellen sinned.') and match its output to an expected value.  # Expected Output: It's a Palindrome!   I appreciate your clear answer for all four requested inputs, with correct printed outputs for each of them. Again, please make sure if it works correctly for each of them, before delivering. Thanks!!!

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Hi there, I need help on the following problem: I got part of the answer but for some list of words collection can't come up with the expected solution. Here is te question:

==============================================

Create a program, palindrome.py, that has a function that takes one string argument and prints a sentence indicating if the text is a palindrome. The function should consider only the alphanumeric characters in the string, and not depend on capitalization, punctuation, or whitespace.

            If your string is a palindrome it should print:

                    It's a palindrome!

            If it is not a palindrome, it should print:

                It's not a palindrome!

======================================

Here is my code and it correctly outputs the answer for the first two in puts, but not for the last two:

def isPalindrome(txt):
if txt == txt[::-1]:
print("It's a Palindrome!")
else:
print("It's not a Palindrome!")


isPalindrome('anna')                # Output: It's a Palindrome
isPalindrome('Hello world')     # Output: It's not a Palindrome!

isPalindrome('Ed, I saw Harpo Marx ram Oprah W. aside') and match its output to an expected value.  #Output should be: It's a Palindrome!


isPalindrome('Dennis, Nell, Edna, Leon, Nedra, Anita, Rolf, Nora, Alice, Carol, Leo, Jane, Reed, Dena, Dale, Basil, Rae, Penny, Lana, Dave, Denny, Lena, Ida, Bernadette, Ben, Ray, Lila, Nina, Jo, Ira, Mara, Sara, Mario, Jan, '
'Ina, Lily, Arne, Bette, Dan, Reba, Diane, Lynn, Ed, Eva, Dana, Lynne, Pearl, Isabel, Ada, Ned, Dee, Rena, Joel, Lora, Cecil, Aaron, Flora, Tina, Arden, Noel, and Ellen sinned.') and match its output to an expected value.

 # Expected Output: It's a Palindrome!

 

I appreciate your clear answer for all four requested inputs, with correct printed outputs for each of them. Again, please make sure if it works correctly for each of them, before delivering. Thanks!!! 

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education