Practice Makes Perfect. 7.reverse


#1

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.


#2

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.


#3

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