Q:

How do I create a generator within a generator- Python

If I created a list:
_list = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]

and tried to get every value <= 6 by using a generator:
test = next(i for i in a for a in _list if i <= 6)

(btw this doesn't work ↑↑↑↑↑)
How do I iterate through lists within a list using a generator? If this is not possible, what method can I use in place of this?
I have looked here:
python generator of generators?, but could not find an answer...

A:

Using chain from builtin module itertools:
from itertools import chain

_list = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]

print(list(i for i in chain.from_iterable(_list) if i <= 6))

Output:

[1, 2, 3, 4, 5, 6]

What itertools.chain does? According manual pages:

Make an iterator that returns elements from the first iterable until
  it is exhausted, then proceeds to the next iterable, until all of the
  iterables are exhausted. Used for treating consecutive sequences as a
  single sequence.

