Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #29483
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <dwightdhutto@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.041 |
| X-Spam-Evidence | '*H*': 0.92; '*S*': 0.00; 'received:mail- vc0-f174.google.com': 0.09; 'cc:addr:python-list': 0.10; 'dictionaries': 0.16; 'keys.': 0.16; 'keys': 0.22; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'message-id:@mail.gmail.com': 0.27; 'received:209.85.220.174': 0.29; 'though.': 0.29; 'print': 0.32; 'values.': 0.33; 'skip:d 20': 0.34; 'received:google.com': 0.34; 'list': 0.35; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'ones': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'where': 0.40; 'header:Received:5': 0.40; 'here': 0.65 |
| 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:to :cc:content-type; bh=PIpON0B/pDcVKMzCY7e2RoRWMinpeZ+3D99R9M1iLoQ=; b=XHfwdO6DchZ2GiBHqvsGk34QGSYj8DtRw3IyQaj22OMWDRYiRbjMOQbv/c8jGHTINW oHj5spOdRVlCvkYv/bWofnmtIEHCPkbZleZOHM7OnbUgfC3JpMv7jdLw2Ks/Yvv6D7Um AJU2tCoY71QEHjejgk5RpWA/afkFkziCQcAwW1gQkefRHU3Tk2wAZ8IqUjsjLpHTGoye g5mHikY9j+kCntW/nvyvnNrqKSgAjoFzft3ET/HXNHdF5kWOD+9/Q0AZvi+Db3NZa1yy 966Fk9FSrhGWAqsZShHNQuR1T/4Rs4SkNTc5WSGJ5T67P974iC8xzemoQVibD99TzSpA OUhA== |
| MIME-Version | 1.0 |
| In-Reply-To | <k3c9jb$2gr$1@ger.gmane.org> |
| References | <k3c9jb$2gr$1@ger.gmane.org> |
| Date | Wed, 19 Sep 2012 08:01:11 -0400 |
| Subject | Re: A little morning puzzle |
| From | Dwight Hutto <dwightdhutto@gmail.com> |
| To | Neal Becker <ndbecker2@gmail.com> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.910.1348056073.27098.python-list@python.org> (permalink) |
| Lines | 38 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1348056073 news.xs4all.nl 6863 [2001:888:2000:d::a6]:52687 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:29483 |
Show key headers only | View raw
> I have a list of dictionaries. They all have the same keys. I want to find the
> set of keys where all the dictionaries have the same values. Suggestions?
Here is my solution:
a = {}
a['dict'] = 1
b = {}
b['dict'] = 2
c = {}
c['dict'] = 1
d = {}
d['dict'] = 3
e = {}
e['dict'] = 1
x = [a,b,c,d,e]
collection_count = 0
for dict_key_search in x:
if dict_key_search['dict'] == 1:
collection_count += 1
print dict_key_search['dict']
Might be better ones though.
--
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: A little morning puzzle Dwight Hutto <dwightdhutto@gmail.com> - 2012-09-19 08:01 -0400
csiph-web