On Fri, Oct 9, 2009 at 11:02 PM, Kent Johnson <[email protected]> wrote: > On Fri, Oct 9, 2009 at 3:54 AM, Stefan Lesicnik <[email protected]> wrote: > > You can easily keep track of the previous item by assigning it to a > variable. For example this shows just the increasing elements of a > sequence: > > In [22]: items = [0, 1, 3, 2, 8, 5, 9 ] > > In [23]: last = None > > In [24]: for item in items: > ....: if last is None or item > last: > ....: print item > ....: last = item
Darn... this is what happens when you're stuck on one solution (referring to my index-only ways in the last post) - you miss other obvious ways, duh * 10. Apologies for the unnecessarily complicated exposition on iterables above. :-( -- There is more to life than increasing its speed. -- Mahatma Gandhi _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
