You could flatten the list first:
d = [v for x in c for v in x if v in range(5, 45)]
In the code you posted, you have x for x in c
in your list comprehension. Each x
here is one of the sublists (say, for example [1,1,12]
). This being a list
will never satisfy: x in range(5,45)
since range()
will be looking for a single integer and not a list
. Code in the form x in y
never looks inside x
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…