This question is a little harder. Create a generator function called listgen(n)
that yields numbers from 0 to n, in batches of lists of maximum 10 numbers at a time. For example, your function should behave as follows:
g = listgen(100)
next(g)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
next(g)
[10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
next(g)
[20, 21, 22, 23, 24, 25, 26, 27, 28, 29]
Given this 3x4 matrix implemented as a list of lists, write a list comprehension that creates its transpose:
matrix = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]