Simple Dictionary Problem

Kris Caselden google at hanger.snowbird.net
Mon Aug 25 05:06:56 CEST 2003


I'm still new to some of Python's finer details, so this problem is
probably an easy fix. I can't seem to loop through a dictionary whose
values are tuples.

For instance:

oldlist = {'name':(1,2,3)}
newlist = []
for x1,x2 in oldlist:
    for y1 in x2:
        newlist.append(str(x1)+str(y1))
print newlist

Gives me:

line 3, in ?
    for x1,x2 in oldlist:
ValueError: too many values to unpack

The docs I've read mention problems where the key is immutable, but
don't say anything about what data-types are acceptable for the value.
What am I missing?




More information about the Python-list mailing list