Lesson 15 broken?


#1

Hi everyone, either something weird is going on with my code or this lesson is broken. I am on lesson 15. Practice makes perfect.
Here is my code:


def reverse(string):
reverse = " "
length = int(len(string)) - 1
for char in string:
character = string[length]
reverse = reverse + character
length = length - 1
return reverse
print reverse


I've tested the code and it works, but Codecademy gives me the following error message:

Oops, try again. Your function fails on reverse("Python!"). It returns " !nohtyP" when it should return "!nohtyP".

It returns exactly what it is requesting but it does not let me proceed.


#2

Initialize this variable as the empty string, no white space.

len(string) is already an integer. No conversion or declaration necessary.


#3

Thank you! I didn't even notice the white space.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.