On Sat, 11 Aug 2012 17:54:40 -0700, Paul Rubin wrote: > John Ladasky <john_lada...@sbcglobal.net> writes: [...] >> If the length of the list L is odd, I want to process it once. If >> len(L) is even, I want to process it twice.... >> for x in range(1 + not(len(L) % 2)): > > If you really have to do something like that, I'd say > > for x in range(1 + (len(L) & 1)): [snip]
I'd simplify it even more: for x in (0,) if len(L)%2 else (0, 1): ... which is even more explicit and simpler to read even though it is longer. -- Steven -- http://mail.python.org/mailman/listinfo/python-list