fork download
  1. n = 8
  2. res = [y for x in range(1, n+1) for y in [x] * x]
  3. print(res)
  4.  
Success #stdin #stdout 0.02s 9052KB
stdin
Standard input is empty
stdout
[1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8]