Reverse() - error


#1

Bellow is my code, (By The Way, a ~ equals a space for indentation)

----Code-Begins---

def reverse(x):
~~~~x = str(x)
~~~~y = len(x)
~~~~~~~~for i in x:
~~~~~~~~print str(x)[::-y]
~~~~~~~~y = y-1

x = 'wordy'
print reverse(x)
print reverse("kuff")

---End-of-Code---

The output is:

'''
y
yw
yo
yrw
ydrow
None
f
fk
fu
ffuk
None
None
'''

The code works, not neatly, but it works.

Codecademy Python console is telling me that my function is returning "None" when it should be returning "!nothyP".

But the last bit of output from my code is "!nothyP" when entering
x = "python"
or
reverse("Python!")

Occasionally I receive the "Hey now! No using [::-1] or reversed()." error message.
But [::-y] isn't the same as [::-1] to me.

Any ideas or suggestions?
I could rewrite a new program, but I prefer to improve my current code.
However, I can start over if I need to.

Thank you for your time and consideration. Happy coding!


#2

For this lesson, consider that there are no shortcuts. In other words, don't use slice methods. Use a simple algorithm that iterates the string.