Q: looping with two counter variables through a list
Harald Kirsch
kirschh at lionbioscience.com
Wed Dec 13 02:44:08 EST 2000
In Tcl I can write
set mylist {0 1 2 3 4 5}
foreach {a b} $mylist {
puts $a
}
to print the even numbers of $mylist. Obviously
mylist = [0, 1, 2, 3, 4, 5]
for a,b in mylist:
print a
does not work (ValueError: unpack sequence of wrong size).
What is Python's idiom for running with more than one variable through
a flat list?
Harald Kirsch
--
----------------+------------------------------------------------------
Harald Kirsch | kirschh at lionbioscience.com | "How old is the epsilon?"
LION Bioscience | +49 6221 4038 172 | -- Paul Erdös
*** Please do not send me copies of your posts. ***
More information about the Python-list
mailing list