python loop x + 1 times in a list of list until number y
<p>What I want is the list in <code>num</code> loops <code>x + 1</code> everytime until <code>y</code> is generated(and loops is stoped), which is a large number.</p>

<pre><code>def loop_num(y):
    num = []
    num.append([1])
    num.append([2,3])
    num.append([4,5,6]) 
    num.append([7,8,9,10]) 
    ... #stop append when y in the appended list
    #if y = 9, then `append [7,8]` and `return num`
    return num


# something like[[1 item], [2items], [3items], ...]
# the number append to the list can be a random number or ascending integers. 
</code></pre>

<p>sorry for not clear</p>

<pre><code>def loop_num(x):
    i=1
    cnt=0
    sum=0
    while sum&lt;x:

        sum+=i
        cnt=cnt+1
        i=i+1

    num=[ [] for x in range(cnt)]

    count=0

    sz=1
    init=1
    while(count&lt;cnt):
        cur=1
        while(cur&lt;=sz):
            num[count].append(init)
            init=init+1
            cur=cur+1
        count=count+1
        sz=sz+1;
    return num
</code></pre>

<p>From a python file you may run it from command line (say filename is test.py)</p>

<pre><code>python -c 'import test; print test.loop_num(55)'
</code></pre>

python list loops random iteratee