Example Input and Output:
Input: “A man a plan a canal Panama”
Output: “The string is a palindrome.”
Input: “Hello, World!”
Output: “The string is not a palindrome.”
Requirements:
The program should handle various cases, such as:
Ignoring spaces and punctuation.
Treating uppercase and lowercase letters as the same.
Bonus Challenge:
Modify the program to return the palindrome found within a longer string if applicable.
What I Tried:
Palindromic Check: I implemented a Python program to check if a string is a palindrome.
Test Cases: I tested the program with various inputs, including:
“A man a plan a canal Panama”
“Hello, World!”
“Racecar”
“No lemon, no melon”
What I Expected:
For the input “A man a plan a canal Panama,” I expected the program to return that it is a palindrome because when stripped of spaces and punctuation, it reads the same forwards and backwards.
For the input “Hello, World!”, I expected the output to indicate that it is not a palindrome.
For “Racecar,” I expected it to confirm that it is a palindrome.
For “No lemon, no melon,” I anticipated it would also confirm that it is a palindrome.
Madhu Shri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.