Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to select a serie of sublists according to an other list

One more time this is certainly the result of my lack of expertise in programming but I encounter the following problem.

I have a list of lists

A=[[3, 2, 1, 1, 0, 0, 0, 5],   [4, 3, -1, 0, -1, 1, 0, 4],   [1, 2, 2, 0, 0, 0, 1, 2]]

and an other list

B=[3,5]

What I want is to select a sublist of the list A according to the following criterion : keep the sublist A[i] if A[i][j]==1 for j in B