Hi all, I was hoping to get some help with a problem I have.

I have a function that is outputting this result:

test = [[11,22,33,44,55,66]]

which I have reason to believe is a nested array? eg. [[11,22],0] or something like this.

My question, is it possible to manipulate 'test' to get the numbers out of the array. Like creating a loop to let a = 11, 22, 33 ....

I am completly stuck on this and have not been able to find a way to do this after LOTS of searching. Any help would be greatly appreciated!

Recommended Answers

All 2 Replies

It's very simple. test[0] is the inner array, so you can write

for num in test[0]:
    # do something with num

Sometimes a few test prints are a real eye opener:

test = [[11,22,33,44,55,66]]

print(test[0])     # [11, 22, 33, 44, 55, 66]
print(test[0][0])  # 11
print(test[0][1])  # 22
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.