I'm a firm believer in, "You must be able to do a portion of the task manually so that you understand what you're doing. Only then can you begin the coding process."
So, how would you **manually** check the following phrase to see if it's a palindrome:
Madam, I'm Adam
How about:
1. Get the user's input. We did. It's: Madam, I'm Adam
2. Consider removing any punctuation and spaces, which leaves: MadamImAdam
3. Convert to lowercase and count the size of the phrase: madamimadam -- 11 chars.
If the size is an even number, split the phrase in half and compare each char. (See example)
If the size is an odd number, subtract 1 then split the phrase in half (this omits the middle char) and compare each char. (Again, see the example)
Example: Madam, I'm Adam
After doing steps 1-3, we have: madamimadam = 11 chars
a. subtract 1, gives us 10. Cut 10 in half, you get 5.
b. Grab the 1st 5 chars from the front and the last 5 chars from the rear.
c. Compare char 1 in string-1 to char 5 in string-2, and so on...
d. If they're equal you have a palindrome.
Some test phrases and the expected result:
------------------------- --------------------------------
Madam, I'm Adam -- (Palindrome)
Madam, I am Adam -- (NOT a Palindrome)
Eva, Can I Stab Bats In A Cave? -- (Palindrome)
Eva, Can I Stab Bats In A Cove? -- (NOT a Palindrome)
A Man, A Plan, A Canal -- Panama! -- (Palindrome)
A Man, A Plann, A Canal -- Panama! -- (NOT a Palindrome)