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


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

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"    


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