Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!news2.arglkargh.de!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1.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.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'wrote': 0.14; '(x,': 0.16; 'caveat': 0.16; 'dictionary,': 0.16; 'finney': 0.16; 'received:80.91.229.3': 0.16; 'received:97': 0.16; 'received:plane.gmane.org': 0.16; 'header:X -Complaints-To:1': 0.27; 'keys': 0.31; 'writes:': 0.31; 'lists': 0.32; 'compatible': 0.32; 'one,': 0.35; 'subject:lists': 0.35; 'ben': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'such': 0.63; 'wish': 0.70 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dave Angel Subject: Re: Combining lists to dictionary Date: Wed, 12 Nov 2014 01:13:33 -0500 (EST) Organization: news.gmane.org References: <85tx255ib8.fsf@benfinney.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: 97.73.240.77 X-Newsreader: PiaoHong.Usenet.Client.VIP:1.65 X-Archive: encrypt 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: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1415772907 news.xs4all.nl 2868 [2001:888:2000:d::a6]:35556 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:80591 Ben Finney Wrote in message: > Denis McMahon writes: > >> Hi >> >> Given x,y are a lists of keys and value that I wish to combine to a >> dictionary, such that x[n] is the key for value y[n], which is preferred: >> >> z = {a:b for (a,b) in zip(x,y)} > > This one, with the caveat to use PEP-8 compatible formatting:: > > z = {a: b for (a, b) in zip(x, y)} Or just z = dict(zip (x, y)) > -- DaveA