how can create list of consecutive numbers each number repeats n times, example:
list = [0,0,0,1,1,1,2,2,2,3,3,3,4,4,4,5,5,5]
another idea, without need other packages or sums:
[x//n x in range((m+1)*n)]
where n
number of repeats , m
maximum value repeat. e.g.
n = 3 m = 5 [x//n x in range((m+1)*n)]
yields
[0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]
Comments
Post a Comment