Looping around a simple list of tuples
Martin d'Anjou
point14 at magma.ca
Sun Apr 27 00:45:16 EDT 2003
I have a list of tuples, each tuple is a (scalar , list)
a=[("r1",[1,2,3]),("r2",[8,9,10]),("r5",[12,14,16])]
for el in a:
print el
for r,l in el:
print "R "+`r`
print "L "+`l`
('r1', [1, 2, 3])
R 'r'
L '1'
Traceback (innermost last):
File "<stdin>", line 3, in ?
ValueError: unpack list of wrong size
In my mind, the 'el' implicit variable is a tuple, and the for r,l loop should
just work but it does not. How come?
Thanks,
Martin
More information about the Python-list
mailing list