Is there a better algorithm?

Paul Rubin http
Fri Jan 2 15:58:24 EST 2009


Kottiyath <n.kottiyath at gmail.com> writes:
> I have the following list of tuples:
> L = [(1, 2), (3, 4, 5), (6, 7)]
> I want to loop through the list and extract the values.

Others have suggested messy ways to code what you're asking.  At another
level, that list format seems like a code smell.  You may be better off
organizing the program so that

   L = [(1, None, 2), (3, 4, 5), (6, None, 7)]

after which unpacking becomes trivial.



More information about the Python-list mailing list