Skip to content
Advertisement

Creating a palindrome checker with Python’s loop and if statements

I am trying to follow the instructions to create a palindrome. I am given half a function, and I have to fill in the blanks. I am currently unable to get the loop to work correctly. I am also unsure how to add characters to the beginning or the end of string without using the + or a comma. I do not think that is what I am being asked to do. Here are the instructions;

The is_palindrome function checks if a string is a palindrome… Fill in the blanks in this function to return True if the passed string is a palindrome, False if not.

JavaScript

I have removed the empty spaces and made everything the same case. I have assigned the characters to new_string, but it looks like I am supposed to use join to add the characters, but when I do the print statement does not print anything. I am unsure how to add the items in reverse order. I am not even sure if I am on the correct track, because I am unsure what the IF statement is asking. I would think I should be able to use a loop to create the string and then compare the two strings.

Also, could someone please explain why new_string.join(word) does not print anything out? How am I using it incorrectly?

Thank you very much for any possible assistance.

Advertisement

Answer

It worked for me, I have tried and change little bit from above my code it work now with below code.

You can see it pass in their test and code verification, refer below screenshots and code.

enter image description here

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement