Question: answer in python please. The first step is to get a string from the user. This string might have any amount of whitespace in it,
answer in python please. The first step is to get a string from the user. This string might have any amount of whitespace in it, which could throw off our code for checking if this string is a palindrome. Once you have a string from the user, you should use some combination of strip, split, and join to remove whitespace. You should also force the string to be all lowercase letters using lower.Now that the code to get rid of whitespace is complete, it is time to traverse the string one character at a time. For now, we won't worry about checking whether or not a string is a palindrome. We will just make sure that we can go through the string one character a time. You should write a loop to do this, and if you want you can print out the index of each character along with it. Now it's time to check if the string is a palindrome. For this part to work, you should think about how you can use your traversal loop to check two characters at the same time. You already have the current index stored in a variable, but now you need to figure out how to check the character on the opposite side from the index that you have. Can you come up with a mathematical expression to do that? Once you've figured out an expression, now you have to use it to check if the string is a palindrome. Since you are already traversing the string, all you have to do is check and make sure that each character pair is a match, and once you find a mismatch you know that string is not a palindrome. Something like a Boolean flag will be very useful here.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
