Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Paul Rubin Newsgroups: comp.lang.python Subject: Re: Loop thru the dictionary with tuples Date: Sun, 25 May 2014 05:59:39 -0700 Organization: Nightsong/Fort GNOX Lines: 11 Message-ID: <7x61kuc8uc.fsf@ruckus.brouhaha.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx05.eternal-september.org; posting-host="8ff39c3b56f8fea9a226ae9d8294e48e"; logging-data="5935"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX193R6OI8qFNNIKQ5gtdib2p" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:5yXayydsog0GwS4/sSidj2mtBow= sha1:Wc1ZiD8+ObbNA/DYpEp62wpL85w= Xref: csiph.com comp.lang.python:72003 Igor Korot 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.