MRAB wrote:
>  >>> a = [(4, 1), (7, 3), (3, 2), (2, 4)]
>  >>> b = [2, 4, 1, 3]
>  >>> d = dict((v, k) for k, v in a)
>  >>> c = [(d[s], s) for s in b]
>  >>> c
> [(3, 2), (2, 4), (4, 1), (7, 3)]

ah, that is more efficient than the suggestions i posted.

andrew


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to