I have a generator function generate which yields 5 random numbers one at a time. I need to be able to generate the numbers in two ways:
generate
you should use itertools.chain.from_iterable
return itertools.chain.from_iterable(generate(value) for value in values)