Hi Guys,
I'm currently making the transition from matlab to python and am having some difficulties with nesting for loops.
Below is a rough example of what I'm trying to do. However when this executes abc is only returned as [] and not a 1D array of each iteration.

Any help would be greatly appreciated.


    for j in range(n-1,0):
        for i in range(0,j):
            a=2**i * 3**(j)
    print abc

what is this supposed to mean, n is not <= 0?


If I assume you mean range(n-1) (loop 0, 1, 2, 3) then the same result I would make with this with list comprehension

n = 5
print [2**i * 3**j for j in range(n-1) for i in range(j)]

Thanks for the reply.


is meant to mean a decreasing sequence from n-1 to 0. I think see my error, it's matlab terminolgy.
It should instead read


You said until 0, but this is down to 1 loop, end is not inclusive (n-1 numbers starting from n-1).