7/15 reverse


Hi, I was wondering if anyone could tell me why my code stops at "!" instead of looping through the amount of times needed to get "!nohtyP"? Any and all feedback is appreciated. Thanks!

*astericks are used to show indentation (not on my actual code).

def reverse(text):
    reverse= ""
    for i in range(len(text)):
         reverse += text[len(text)-count]
         return reverse

15/7 reverse not passing

I'm also just a beginner like you so this solution might not work. Your variable count
= 1 is inside the for loop. It should be outside or it will keep resetting to 1 each loop and therefore always output the same letter.


Hi, I understand almost all your function, except for that "+" in "count+=1". Could you tell me what is it for?


There are two problems, first off, i hope you return is indented differently. I would put it on the same indent level as your for loop, so it returns the reversed text after it finished the for loop, and not in the first run (function ends when return is reached)

I would define count (count = 1) before your for loop, not in your for loop, otherwise count is set to 1 each run of your for loop, which is going to do you reverse no good. If you take this steps, it should work, if not, post an updated version of your code.

for next time, use one of the two following options to make your code/indent is visible (so you don't have to use asterixs):

select your code and press ctrl + shift + c (or cmd + shift + c if you use a mac)

if this instructions are unclear, you can also insert 3 backticks before and after your code, like so:


the backtick is located above the tab key on your keyboard


You keep resetting count to 1 every time it goes through the loop try moving out of the for loop.


Thanks yusrighouse! That def was the problem! :slightly_smiling: