Why is my code generating "c b a ! n o h t y P", i havent used lists in my program


#1

The output is always - “c b a ! n o h t y P”, and my function call returns: “e m i T T”, I don’t understand where the ‘cba’ and the extra ‘T’ coming from?

def reverse(text):
rev = 0
n = len(text)
for i in range((n - 1), -1, -1):
rev = text[i]
print rev,
return rev

print reverse(“Time”)


#2

please read this topic:

Scrabble_score reciving more input than the error notes

i know its a different exercise from the track you are on, but it discusses the same problem


#3

thanks, I finally had to change the code to avoid writing the print statement:

def reverse(text):
rev = 0
revstore = “”
n = len(text)
for i in range((n - 1), -1, -1):
rev = text[i]
revstore += rev
return revstore

print reverse(“Python!”)


#4