When I run the following code, it shows the reverse working correctly for any string I pass to reverse(). However, when I remove the final print command, the error message I get states:
"Oops, try again. Your function fails on reverse("Python!"). It returns "Pyt!nohtyP" when it should return "!nohtyP".
My concept was to build a list with the correct number of letters (if I didn't I was getting an error as the list didn't have anything in it), then replace each one using the index of each item but counting down, not up.
When I run the code (as shown - with the final print command), the result on the console is "987654321"
rev_list =  def reverse(text): count = 0 for n in text: rev_list.insert(count, str(n)) count += 1 count = len(rev_list) - 1 for x in text: if count >= 0: print count rev_list[count] = str(x) count -= 1 print rev_list a = "" for st in rev_list: a = a + st return a print reverse("123456789")