I have the following list:
l = [5, 6, 7, 1]
I need to populate this list with the first value (i.e. 5) so that the length of this list becomes equal to 10.
Expected result:
l_extended = [5, 5, 5, 5, 5, 5, 5, 6, 7, 1]
I can do it in for loop:
fixed_val = l[0]
len_diff = 10 - len(l)
l_extended = []
for n in range(len_diff):
l_extended.append(fixed_val)
for n in range(len_diff,10):
l_extended.append(l[n-len_diff])
But is there any shorter way to do it?