efficient list mapping in python

Posted by Joey on Stack Overflow See other posts from Stack Overflow or by Joey
Published on 2010-04-28T11:54:44Z Indexed on 2010/04/28 12:13 UTC
Read the original article Hit count: 318

Filed under:
|
|
|
|

Hi everyone,

I have the following input:

input = [(dog, dog, cat, mouse), (cat, ruby, python, mouse)]

and trying to have the following output:

outputlist = [[0, 0, 1, 2], [1, 3, 4, 2]]

outputmapping = {0:dog, 1:cat, 2:mouse, 3:ruby, 4:python, 5:mouse}

Any tips on how to handle given with scalability in mind (var input can get really large).

© Stack Overflow or respective owner

Related posts about python

Related posts about list