Is there a better algorithm?
gh at ghaering.de
Fri Jan 2 22:16:26 CET 2009
> 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.
> The only algorithm I could think of is: [...]
If this is part of a real program, instead of an exercise, you should
fix the code that creates this list of tuples so that they have a
uniform length of 3. And if the third element is missing, it should be None.
This saves lots of trouble later on.
More information about the Python-list