How to detect the last element in a for loop

François Pinard pinard at iro.umontreal.ca
Sun Jul 28 13:48:20 EDT 2002


[Tom Verbeure]

> Then what about this?

> for a in myList:
>     if last_one:
>         special_stuff
>     do_stuff

Eh!  Some require a bit more work than others :-).

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard




More information about the Python-list mailing list