Assume that I have a matrix:
a = [[4,7,2],[0,1,4],[4,5,6]]
And I want to get
b = [0, 1]
c = [[2],[0,1]]
b = [0,1]
because the inner lists ofa
at position0
and1
contain values that are smaller then3
.c = [[2],[0,1]]
because the[2]
nd element of the first sublist inb
is below 3 and[0,1]
because the first and second element in the second sublist inb
is below 3.
I tried :
for i in a:
for o in i:
if o < 3:
print(i)
It only returns the original matrix.
How do I get b
&c
in python?