I wonder if there is a more elegant way to do the following. For example with list comprehension.
Consider a simple list :
l = ["a", "b", "c", "d", "e"]
I want to duplicate each elements n
times. Thus I did the following :
n = 3
duplic = list()
for li in l:
duplic += [li for i in range(n)]
At the end duplic is :
['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c', 'd', 'd', 'd', 'e', 'e', 'e']