Objective
Create a Python program with a generator that joins several lists into a single sequence using yield from.
Instructions
- Read an integer
nand thennlines, each with integers separated by spaces (at least one per line). Build a list of lists. - Define
def flatten(lists), which for each sublist yields all its elements withyield from sublist. - Store the values in a list with
list(flatten(lists)). - Show the values on one line, separated by spaces, and then
Items: K.
3
1 2
3
4 5 6
1 2 3 4 5 6
Items: 6
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise