Loop thru the dictionary with tuples
Paul Rubin
no.email at nospam.invalid
Sun May 25 08:59:39 EDT 2014
Igor Korot <ikorot01 at gmail.com> writes:
> for (key,value) in my_dict:
> #Do some stuff
>
> but I'm getting an error "Too many values to unpack".
Use
for (key,value) in mydict.iteritems(): ...
otherwise you loop through just the keys, whicn in your dictionary
happens to be 3-tuples. So you try to unpack a 3-tuple to a 2-tuple
and get a too-many-values error.
More information about the Python-list
mailing list