Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.046 X-Spam-Evidence: '*H*': 0.91; '*S*': 0.00; 'assignment': 0.07; 'cc:addr:python-list': 0.11; 'python': 0.11; '(key,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'hint:': 0.16; 'roy': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'print': 0.22; 'either.': 0.24; 'cc:2**0': 0.24; 'header:In- Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; '25,': 0.31; 'subject:the': 0.34; "i'd": 0.34; 'could': 0.34; 'subject:with': 0.35; 'case,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'next': 0.36; 'so,': 0.37; 'step': 0.37; 'pm,': 0.38; 'either': 0.39; 'matter': 0.61; 'happen': 0.63; 'line,': 0.68; 'smith': 0.68; 'safety,': 0.91; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=ZelIWUv6M18LKJ40cMABSnGMrO8/MM5Q53avamJ+y7g=; b=l4ciBXGfWXgskQx6ypTG7IxyoFdMW0RuLtTzSWrDFzTSKUo0KqsmnaWp6rzQ2pIcbv 8FKLnc/8GNrS+f8oVqYyhPQJ9bHiPpnDkTFCRglr3XhMgnePkdL3a4Yzak21u2oYGE2B 5+RRfk8NxTUO//8suCbPooRhLzKyQtZ5r338+ZIDNj+/Y4NDZiSUZn6wR0ZPaCOY4dB9 NzhuGWAlLNytm9ELY817bVPetZq31GFwXoPuLSGCUgpSUUfgg4xbCTV7btgAEGX9QhhM RgOAQ/1vi2y784sJ2SBZhliWwegoHwUATQ2Gcax2D1dtlX5Ml8Eara7vRoajFouqka33 PabA== MIME-Version: 1.0 X-Received: by 10.220.95.2 with SMTP id b2mr279536vcn.61.1401026335120; Sun, 25 May 2014 06:58:55 -0700 (PDT) In-Reply-To: References: Date: Sun, 25 May 2014 23:58:55 +1000 Subject: Re: Loop thru the dictionary with tuples From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1401026343 news.xs4all.nl 2879 [2001:888:2000:d::a6]:33269 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:72009 On Sun, May 25, 2014 at 11:22 PM, Roy Smith wrote: > Hint: in this case, > it will happen on the assignment line, so, your next step is to print > everything out and see what's going on: > > for thing in my_dict: > print thing > (key, value) = thing Aside: I know that you (Roy) are still using Python 2, but the OP could be on either branch. As a matter of safety, I'd put parens around the print: for thing in my_dict: print(thing) (key, value) = thing That way, it works on either. ChrisA