Hello,<br>
I've been using lists within lists for several
functions, but have been unable, in loop form, to extract data from
them or, in loop for, apply data to them.<br>
<br>
Basically, when extracting data, it only runs 1 loop. Likewise, when initially assigning the data, it only runs 1 loop.<br>
<br>
In the following example, the loop works once for x, and then a full loop (8 times) for y:<br>
<br>
### <br>
rr1=[0,0,0,0,0,0,0,0]<br>
rr2=[0,0,0,0,0,0,0,0]<br>
rr3=[0,0,0,0,0,0,0,0]<br>
rr4=[0,0,0,0,0,0,0,0]<br>
rr5=[0,0,0,0,0,0,0,0]<br>
rr6=[0,0,0,0,0,0,0,0]<br>
rr7=[0,0,0,0,0,0,0,0]<br>
rr8=[0,0,0,0,0,0,0,0]<br>
results=[rr1,rr2,rr3,rr4,rr5,rr6,rr7,rr8]<br>
<br>
<br>
x=0<br>
y=0<br>
while x<8:<br>
while y<8:<br>
value=x+y<br>
results[x][y]=value<br>
y=y+1<br>
x=x+1<br>
<br>
x=0<br>
y=0<br>
while x<8:<br>
while y<8:<br>
print "(",x,", ",y,") is
",results[x][y] ###results[] is a
list of lists<br>
y=y+1<br>
x=x+1<br>
<br>
###<br>
<br>
<br>
The output is simply:<br>
( 0 , 0 ) is 0<br>
( 0 , 1 ) is 1<br>
( 0 , 2 ) is 2<br>
( 0 , 3 ) is 3<br>
( 0 , 4 ) is 4<br>
( 0 , 5 ) is 5<br>
( 0 , 6 ) is 6<br>
( 0 , 7 ) is 7<br>
<br>
<br>
Thanks for the help. I'm sure this is another newbie mistake, but one I'd be greateful to see past.<br>
<br>
-Phil<br>