Reverse - Practice makes perfect


I'm trying to do this exercice, but I have no idea how to do it.
Can someone please help me out. Thank u for the help in advance.
This is the only thing I've done so far:

def reverse(text):
    revr = ""       """set up a blank variable""""
    for i in text:    """set up a for loop"""


Choosing a loop is correct.

It's easier to use the index of the text.

for i in range(len(text)):
result = text[i] + result

This works by forcing i to an index. Then assigning the character that is indexed in text to a result plus the result (which is empty at first). So because result is appended after the indexed char, the characters are concatenated in a reversed order.


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