Need help with Reverse


#1

https://www.codecademy.com/courses/python-intermediate-en-rCQKw/1/1?curriculum_id=4f89dab3d788890003000096

Need help figuring out why this code is not working.

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

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

reverse(Python!)

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.

`


#2

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


#3

This was a big help. Thank you


#4