(If anyone can suggest a better headline, be sure to go ahead and edit).
Given list list1, whose exact length is unknown, but for which it is known, will always be less than or equal to 5, I want to populate a separate empty list list2 with a fixed length of 5, from the value in list1, filling in blank lines if the size of list2 is less than 5.
eg. if list1 = [1,2,3]
then list2 should be [1,2,3, '', '']
etc.
So:
if len(list1) < 5: list2.extend(list1)
What is the easiest way to achieve this (determining the number of blank lines to add)?
source share