In my current Python project, I need to create some long lists of integers for later use in plots. Currently I'm attacking this in the following way:
volume_axis = []
for values in stripped_header:
for doses in range(100):
volume_axis.append(int(values))
This code will append to my blank list, giving me the first value in stripped header 100 times, then the next value in stripped header 100 times etc.
Is there a more elegant and pythonesque way to accomplish this?
for values in stripped_header:
volume_axis += [int(values)] * 100
or using itertools (may be more efficient)
from itertools import repeat
for values in stripped_header:
volume_axis += repeat(int(values), 100)