B
Bruno Desthuilliers
Kottiyath a écrit :
complement = lambda t: (t[0], None, t[1]) if len(t) == 2 else t
for k, u, v in map(complement, L):
print k, u, v
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:... u = None
... try:
... (k, v) = i
... except ValueError:
... (k, u, v) = i
... print k, u, v
complement = lambda t: (t[0], None, t[1]) if len(t) == 2 else t
for k, u, v in map(complement, L):
print k, u, v