7. Reverse - Error despite the code working elsewhere


#1


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

Not sure what is going on here, but whenever I use the code below, CodeAcademy spits out "Oops, try again. Your function fails on reverse("Python!"). It returns "None" when it should return "!nohtyP"."

I have tried this several times using the python that is already loaded on my computer, and it works perfectly. What is going on?


def reverse(text):

	text = str(text)
	charList = []
	reverseList = []	

	for i in text: #Runs through the text string and appends each letter to the forwards-list
		charList.append(i)
	print "DEBUG: ", charList

	n = len(text)-1

	while n >= 0: #runs through the forwards-list to reverse them
		reverseList.append(charList[n])
		n -= 1
	print "DEBUG: ", reverseList

	print ''.join(reverseList) #this should print out the reverse of the input


#2

Never mind. figured it out.

Where I had

print ''.join(reverseList)

it should have read

return ''.join(reverseList)