Need help with a quiz

Can somebody please explain why script.py does not ant to accept my solution?
I mean, I get that there is something wrong with the way script.py reading that last print statement, but I have no idea what exactly ¯_(ツ)_/¯

https://www.codecademy.com/courses/learn-python-3/lessons/python-functions-strings-cc/exercises/every-other-letter

In the next quiz, I’ve got the same result, btw

I mean, the answer is correct. So what it is complaining about?

Hey there and welcome to the forums!! :grinning:

In the future please look at formatting your code to preserve indentation, and allow it to be copy/pasted.
To format code, simply press this button:

And then cpy/paste your code between the backticks:


Your variable final is assigned within a for loop that runs once for every element in

range(-1 , (len(word) * (-1)), (-1))

So when you supply the function with a word parameter containing an empty string, there is nothing to loop for, hence there is no variable final to return.

Can you figure out how to compensate for this?

Hint if you need it

How do you assign lst, so that you can modify it in the loop without resetting it?
You have to create it first outside the loop, and then allow the loop to modify.
It is a different reason here for why you would do this, but the concept is the same

1 Like