Question about nested loop

Isaac Won winefrog at gmail.com
Mon Dec 31 17:02:52 EST 2012


On Monday, December 31, 2012 5:25:16 AM UTC-6, Gisle Vanem wrote:
> "Isaac Won" <winefrog at gmail.com> wrote:
> 
> 
> 
> > while c < 10:
> 
> >        c = c + 1
> 
> > 
> 
> >        for  columns in ( raw.strip().split() for raw in f ):
> 
> > 
> 
> > 
> 
> >                b.append(columns[c])
> 
> > 
> 
> >        y = np.array(b, float)
> 
> >        print c, y
> 
> > 
> 
> > 
> 
> > I thought that  can get the arrays of the columns[5] to [10],
> 
> > but I only could get repetition of same arrays of columns[5].
> 
> 
> 
> I don't pretend to know list comprehension very well, but 
> 
> 'c' isn't incremented in the inner loop ( .. for raw in f). 
> 
> Hence you only append to columns[5].
> 
> 
> 
> Maybe you could use another 'd' indexer inside the inner-loop?
> 
> But there must a more elegant way to solve your issue. (I'm a
> 
> PyCommer myself).
> 
> 
> 
> --gv

Thank you for your advice.
 I agree with you and tried to increment in inner loop, but still not very succesful. Anyway many thanks for you.



More information about the Python-list mailing list