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!!!
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!!!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images