Another version of reverse() - Can someone tell me what this does?


#1


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


Here's the result:
['a', 'd', 'f', 's']
['a', 'd', 'f', 's']
['a', 'd', 'f', 's']
['a', 'd', 'f', 's']
None

w/ error: Your function fails on reverse("Python!"). It returns "['!', 'P', 'h', 'n', 'o', 't', 'y']" when it should return "!nohtyP".


def reverse(string):
    l = list(string)
    for i, c in enumerate(l):
        i = len(string)-1-i
        l = sorted(l)
        print l 
    return l

string = "asdf"    
reverse(string)


#2

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