Topic: Loops, Practice makes perfect, Reverse. Whats wrong with this code?


#1

def reverse(x):
new =" "
for i in range(len(x)):
print x[(len(x)-1) - i],
if i == len(x):
break

reverse("Python!")

I do get desired output i.e. ! n o h t y P


#2

You should return a value (reversed string), not print it out.


#3

Thank you, I figured it out just a second ago