Reverse function


Reverse Function.
Here is my solition:

def reverse(text):
for i in range(1,len(text)+1):
return a

Is there any better way?

Replace this line with your code.


better in what way? Readability? Performance?

your program could improve on performance, strings are immutable in python, so here:


a new string is created with the combined result, this takes more memory then when a list is used


So the better way is creating list and join it in string?


performance wise that will be a improved, yes


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