Practice Makes Perfect. 7.reverse


def reverse (text):
rev_text = ""
count = -1
for i in text:
rev_text = rev_text + text[count]
count -= 1
return rev_text
print reverse("Python!")

Output is !nohtyP

i did this and get the correct answer, but confused. Can anyone explain.. rev_text = rev_text + text[count] & count -= 1 works..Thanks in advance.. :slight_smile:

Replace this line with your code.


This strikes me as being copied code that gives the correct answer but one does not know how that is. Am I reading this correctly? Which brings up the second question, does it help if we explain it, or is it better if you go back and do it again, some other way, just for the satisfaction of actually working out a solution of your own?

The mechanics are simple enough to explain, but the end result could be you not learning on your own.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.