The question I am trying to answer is this:
Create a function numstack(n) that returns a list of integers from 1 to n (inclusively) but where each integer mm in the list appears, consecutively, a total of mm times, so that, for example:
numstack(4) = [1,2,2,3,3,3,4,4,4,4]
So far my best attempt has been:
def numstack(n):
for i in range(1,n+1):
z = [i]*i
return z
print(numstack(3))
But this is far from correct, any ideas of how to do this?