Hi,

In this case, I'd go for the simple old fashioned for loop with a boolean:

found = False
for thing in Things:
    if thing.value > 0:
        found = True
    if found:
        thing.value = 2

Remco Gerlich

On Dec 6, 2007 9:48 AM, ted b <[EMAIL PROTECTED]> wrote:

> Can you suggest a good way to iterate through the
> remainder of list and update them?
>
> Ex:
> Thing1.value = 0
> Thing2.value = 1
> Thing3.value = 0
> Thing4.value = 0
>
> Things = [Thing1, Thing2, Thing3, Thing4]
>
> I want to iterate through 'Things' and if
> 'Thing.value' > 0, then I want to set all values for
> that and the subsequent 'Things' in the list to 2
>
> So that i'd end up with
>
> Thing1.value = 0
> Thing2.value = 2
> Thing3.value = 2
> Thing4.value = 2
>
>
>
>  
> ____________________________________________________________________________________
> Be a better friend, newshound, and
> know-it-all with Yahoo! Mobile.  Try it now.
> http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to