Suppose a = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6] and s = [3, 3, 9, 3, 6, 3]. I\'m looking for the best way to repeat a[i] exactly s[i]
a = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6]
s = [3, 3, 9, 3, 6, 3]
a[i]
s[i]
Here's a one-liner using only (nested) list comprehensions:
[item for z in [[x]*y for (x,y) in zip(a, s)] for item in z]