Multiple tuples for one for statement
Ivan Van Laningham
ivanlan at pauahtun.org
Mon Apr 25 10:03:37 EDT 2005
Hi All--
"R. C. James Harlow" wrote:
>
> On Monday 25 April 2005 14:34, Ivan Van Laningham wrote:
> > Hi All--
> >
> > "R. C. James Harlow" wrote:
> > > or just:
> > >
> > > for a,b,c in (tup1, tup2, tup3):
> > > print a
> > > print b
> > > print c
> >
> > And this works in Python version???
>
> Ah, reading the replies to the original post, this works but doesn't give the
> result that the original poster wanted.
>
Define "works":
a=(1,2,3,4,9,43,256,8,2021)
b=(1,0,3,4,7,999,256,8,2023)
c=(1,7,8,4,9,43,4444,8,2028)
for x,y,z in (a,b,c):
print x,y,z
12 [/c/CDListings][8] python fneeg.py
Traceback (most recent call last):
File "fneeg.py", line 8, in ?
for x,y,z in a,b,c:
ValueError: too many values to unpack
PyVersion:
Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
Metta,
Ivan
----------------------------------------------
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps: Cu Chi, Class of '70
Author: Teach Yourself Python in 24 Hours
More information about the Python-list
mailing list