Smallest way to expand a list by n
list, python
Solution
>>> l = [1,2,3,4]
>>> [it for it in l for _ in range(2)]
[1, 1, 2, 2, 3, 3, 4, 4]
Problem
i want to expand a list ``` [1,2,3,4] ``` by n e.g. for n = 2: ``` [1,1,2,2,3,3,4,4] ``` I'm searching for the smallest possible way to achieve this without any additional librarys. Its easy to do a loop and append each item n times to a new list... but is there a other way?