0

I have a list that looks like this:

N_y=[[[1,2,3],[4,5,3],[2,5,8]]]

How do I breakdown N_y to just one list of items, ie:

Output expected: [[1,2,3],[4,5,3],[2,5,8]]

My attempt:

j=str(N_y)[1:-1]
print j

Output "[[1,2,3],[4,5,3],[2,5,8]]"

The problem now is, j comes out as a sting. Is there a quick method for de-listing without outputting strings?

Any suggestions? Thanks.

4

2 回答 2

6

You can simply fetch the inner list:

N_y = N_y[0]

If N_y initially contains:

[[[1, 2, 3], [4, 5, 3], [2, 5, 8]]]

Afterwards, it will contain:

[[1, 2, 3], [4, 5, 3], [2, 5, 8]]
于 2013-09-30T08:24:44.923 回答
2

You can try like this,

>>> N_y[0]
[[1, 2, 3], [4, 5, 3], [2, 5, 8]]
>>> 
于 2013-09-30T08:25:03.663 回答