[Tutor] iterating over less than a full list

Nitin Pawar nitinpawar432 at gmail.com
Sat Sep 4 19:21:23 CEST 2010


if its a dictionary, then I think you will need to use limit

if its normal array you can use range(0,10) and access some_stuff[i]

On Sat, Sep 4, 2010 at 10:44 PM, Bill Allen <wallenpb at gmail.com> wrote:

> Say I have and iterable called some_stuff which is thousands of items in
> length and I am looping thru it as such:
>
> for x in some_stuff
>      etc...
>
> However, what if I want only to iterate through only the first ten items of
> some_stuff, for testing purposes.  Is there a concise way of specifying that
> in the for statement line?
>
>
> -Bill
>
>
>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>


-- 
Nitin Pawar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100904/31f4b647/attachment-0001.html>


More information about the Tutor mailing list