[Tutor] How to iterate and update subseqent items in list

ted b phpmoonlighter at yahoo.com
Thu Dec 6 09:48:56 CET 2007


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 



More information about the Tutor mailing list