Reputation: 8131
I first create my grid:
grid = []
for x in range(1,collength + 1):
for y in range(1,collength + 1):
grid.append([x,y,'e'])
Then I make que for my grid and I want to manipulate the que based on the 0, 1, and 2 position of the lists inside the lists:
floodfillque = []
grid = floodfillque
for each in floodfillque:
floodfilllist = []
currentfloodfill = []
print '::'
print each[1]
But when I try to print each[1] I get the whole list, not just the nth element of the list inside the list
What am I doing wrong?
Upvotes: 0
Views: 3401
Reputation: 838146
As you have written it, your code iterates over an empty list. I think you mean:
for each in grid:
or perhaps:
floodfillque = grid
This code works fine:
collength = 3
grid = []
for x in range(1,collength + 1):
for y in range(1,collength + 1):
grid.append([x,y,'e'])
for each in grid:
floodfilllist = []
currentfloodfill = []
print '::'
print each[1]
Result:
:: 1 :: 2 :: 3 :: 1 :: 2 :: 3 :: 1 :: 2 :: 3
Upvotes: 2