Need help with Reverse


Need help figuring out why this code is not working.

def reverse(text):
    rev = []
    x = len(text)
    for i in range(x-1,-1):
    return "".join(rev)

Here is my logic as I see it. What am I missing.


rev is blank list
x is character length of argument (7)
iterate through the range 6 - 0 (6, 5, 4, 3, 2, 1, 0) with i as the variable
for each iteration append the Python![i] to the empty list rev
this should create a list that looks like ['!', 'n', 'o', 'h', 't', 'y', 'P']
when the iteration is complete join the items of the rev list with no space between and return it.



your mistake is here:

this is currently not happening, you gave two range 2 values, which means they will be the start and stop value, but if you want to go from higher to lower value you need to specify a third argument (steps) for range, otherwise it will attempt to take steps of +1, see range doc


This was a big help. Thank you