PYTHON: Look for match in a nested list

Posted by elfuego1 on Stack Overflow See other posts from Stack Overflow or by elfuego1
Published on 2010-06-13T01:53:05Z Indexed on 2010/06/13 2:02 UTC
Read the original article Hit count: 238

Filed under:
|
|

Hello everybody,

I have two nested lists of different sizes:

A = [[1, 7, 3, 5], [5, 5, 14, 10]]

B = [[1, 17, 3, 5], [1487, 34, 14, 74], [1487, 34, 3, 87], [141, 25, 14, 10]]

I'd like to gather all nested lists from list B if A[2:4] == B[2:4] and put it into list L:

L = [[1, 17, 3, 5], [141, 25, 14, 10]]

Would you help me with this?

© Stack Overflow or respective owner

Related posts about python

Related posts about lists