Pybites Logo

Jagged list

Level: Intermediate (score: 3)

Write a function that takes an irregular shaped list of lists and makes it symmetrical by adding a fillvalue to each sublist:

Example:  

>>> jagged_list([[1, 1, 1, 1], [0, 0, 0, 0], [1]], fillvalue=1)
[[1, 1, 1, 1], [0, 0, 0, 0], [1, 1, 1, 1]]

Hint: Some functions in the itertools module may be useful.