creating an artificial "last element" in sort list

Demian Brecht demianbrecht at gmail.com
Fri Sep 28 20:59:48 EDT 2012


> f = filter(lambda s: s == a[-1], a)

That line's assuming that the last element may also be found in arbitrary locations in the list. If it's guaranteed that they're all contiguous at the upper bounds, I'd just walk the list backwards until I found one that wasn't matching rather than filtering.



More information about the Python-list mailing list