Reputation: 303
I am working with a list of lists and I am using coordinates to work my way through the lists. After starting at coordinates 0,0 my list for neighboring nodes looks like this:
[(0, 1), (1, 0), (1, 1)]
Next I choose the first node so it looks like:
(0, 1)
I want to be able to split up the first number from the second and assign them to i and j so I can keep iterating through the loop. Is there any way to accomplish this? I know of for x in list but that loops through each item which is (0,1) and not each individual number.
Upvotes: 1
Views: 210
Reputation: 251196
Something like this:
In [45]: lis=[(0, 1), (1, 0), (1, 1)]
In [46]: for i,j in lis:
....: print i,j
....:
0 1
1 0
1 1
Upvotes: 3