avatar Bite 296. Jagged list

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.

 

Login and get coding
go back Intermediate level
Bitecoin 3X

61 out of 62 users completed this Bite.
Will you be Pythonista #62 to crack this Bite?
Resolution time: ~23 min. (avg. submissions of 5-240 min.)
Pythonistas rate this Bite 2.67 on a 1-10 difficulty scale.
» You can do it! 😌

Focus on this Bite hiding sidebars, turn on Focus Mode.

Ask for Help