Bill Allen wrote:
Thanks to everyone who replied. Some of the methods presented where some I
had thought of, others were new to me. Particularly, I did not realize I
could apply a slice to a list. The for x in some_stuff[:value] form worked
very well for my purposes. I can also see I need
Thanks to everyone who replied. Some of the methods presented where some I
had thought of, others were new to me. Particularly, I did not realize I
could apply a slice to a list. The for x in some_stuff[:value] form worked
very well for my purposes. I can also see I need to look into the ite
Bill Allen 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
On Sun, 5 Sep 2010 03:14:24 am Bill Allen 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,
On 04/09/2010 18:29, Sander Sweers wrote:
On 4 September 2010 19:25, Sander Sweers wrote:
for x in some_stuff:
if x<= 10:
print x
else:
break
Oops, corrected version...
count = 0
for x in some_stuff:
if count< 10:
print x
count +=1
else:
On 4 September 2010 19:25, Sander Sweers wrote:
> for x in some_stuff:
> if x <= 10:
> print x
> else:
> break
Oops, corrected version...
count = 0
for x in some_stuff:
if count < 10:
print x
count +=1
else:
break
Greets
Sander
___
On 4 September 2010 19:14, Bill Allen 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
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 wrote:
> Say I have and iterable called some_stuff which is thousands of items in
> length and I am looping thru it as su
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 tha