Simple question from Python newb... What am I doing wrong? For x, y, z in aTuple:

Amy G amy-g-art at cox.net
Mon Jan 19 16:15:22 EST 2004


I have a whole bunch of tuples that look something like this,

aTuple = ('1074545869.6580.msg', 't_bryan_pw at gmcc.ab.ca', 'Your one stop
prescriptions')

now that I have this I try

for x, y, z in aTuple:
    do something with x
    do something with y
    do something with z

But I am getting the error that there are too many values to unpack.
If I do...

for x in aTuple:
    print x

It prints the items from the tuple each on its own line.  How can I unpack
these three string values into three different string variables like my
first for loop?

Thanks in advance for answering what is probably a simple question.





More information about the Python-list mailing list