2 May 2003 05:18
Re: while statement
Sean 'Shaleh' Perry <shalehperry <at> attbi.com>
2003-05-02 03:18:36 GMT
2003-05-02 03:18:36 GMT
> > Another method is the for loop, it will save you the manual > incrementing of n: > > for n in range(1, N+1): > do_stuff > > range(x, y) creates a list with the integer elements i, where x <= i < y, > and the for loop will iterate through each element in this list, > assigning the current element to n. > I personally find this horribly wasteful. xrange() at least generates the next element when it is needed. range(1,100) # builds a 100 item list, ick. Sure this is a scripting language, but no need to waste cycles uselessly. _______________________________________________ Tutor maillist - Tutor <at> python.org http://mail.python.org/mailman/listinfo/tutor
RSS Feed