My 'reverse' function in my Terminal but is rejected by Codecademy? please help


#1


https://www.codecademy.com/courses/python-intermediate-en-rCQKw/1/1?curriculum_id=4f89dab3d788890003000096#

Your function fails on reverse("Python!"). It returns "None" when it should return "!nohtyP".

I expect the entry Python! to be returned ! n o h t y P as it does this in my Terminal when i run the code below there but i get the error above in the lesson

Please Help


def reverse(text):
	l = len(text)
	l = l -1
	while l >= 0:
		print text[l],
		l = l - 1


#2

You are printing it out, but you should be returning it. Also, because return ends the function, you will need to store it in a variable, then return it when you're done.


#3

great thank you --- i got it to work with this below:

def reverse(text):
word = ""
l = len(text)
l = l -1
while l >= 0:
word = word + text[l]
l = l - 1
return word