So everyone knows that I can get a list of numbers with range as follows:
>>> range(5) [0, 1, 2, 3, 4]
And if I want, say, 3 copies of each number that I could use:
>>> range(5)*3 [0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4]
But is there a way to use range to repeat copies like this?
[0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]
Is there a quick and elegant built-in way to do this? sorted(range(5)*3) has unnecessary complexity n * log (n), and [x//3 for x in range(3*5)] works, but looks like an abuse of the // operation.