> > def invert(p):
> >     inverse = [None] * len(p)
> >     for (i, j) in enumerate(p):
> >         inverse[j] = i
> >     return inverse
>
> Elegant. This seems like the best solution, although it isn't as much
> fun to write as a "one-liner". Thanks


>>> invert([1, 2, 3, 1])
[None, 3, 1, 2] #blah
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to