Reverse - legal solution?


#1

My question is whether following is a legal solution, since the task includes not to use reversed or [::-1] for the solution.



def reverse(text):
    b=[]
    b_len=len(b)
    for n in text:
        b.append(n)
    b.reverse()
    return ''.join(b) 


I am guessing I ended up writing the underlying function of the “reversed” function :smiley:


#2

you use the .reverse() method, i would consider it cheating. But then, you are here to learn, so its your choice.

the best scenario would be to write your own alrogithm to reverse a given string


#3

Yes I thought so. I will attempt a “legal” solution as well


#4

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