def reverse(text):
    word = ""
    l = len(text) - 1
    while l >= 0:
        word = word + text[l]
        l -= 1
    return word

I don’t understand about this solution. please help me to understand.


What is it you don’t understand?

the short answer is that we loop from the right hand side (len(text) - 1) to the left hand side of text, and then append/add the characters to word, causing the string to reverse


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