Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #29489

Re: A little morning puzzle

Path csiph.com!usenet.pasdenom.info!gegeweb.org!noc.nerim.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.010
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'received:mail- vc0-f174.google.com': 0.09; 'sep': 0.09; 'cc:addr:python-list': 0.10; 'better:': 0.16; 'dictionaries': 0.16; 'keys.': 0.16; 'wed,': 0.16; 'wrote:': 0.17; '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; 'am,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'skip:( 20': 0.28; 'received:209.85.220.174': 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; 'received:209': 0.37; 'subject:: ': 0.38; 'where': 0.40; 'header:Received:5': 0.40
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=eskE/c3CoAoR6BtiHeZnf6xJnYh/hJUXFR+R9+4AdJY=; b=DiKmSHUuf0JNp2ALNR3LcZp0GNMHnrNOnpZaLd7yY3xT//OfOvx5sM4oDvqHshhFtX hnVu3kipOZItBIIKPGtNwQaqxW6WPmpQgMbDq1FdLECeLRBfkwq0HmUWsiNyZ3mdN6hu BzK0vQwsKkXPEK+lVD70FcwfetNu8/Jrzpc+/irBvqnw6XKYb9o+hAcMg+X169lbWzdS J2/PQrnB2MnQKlSVlz6p8aIdUo3aA99UM2hQHmiR918m2+Xa3Peh6r/R5//6UNLFz7MW L1AjGXOrvHmvb8lcHXy7oDkOvZpGCZ7aar4rhpnikZmiPWcoMYhhbuvk3UJw+sJAwp+0 BQYw==
MIME-Version 1.0
In-Reply-To <CA+vVgJXh2PyeAT5LdWD6twijHPhmAoL9UPJxj+QJXvmey-WAgQ@mail.gmail.com>
References <k3c9jb$2gr$1@ger.gmane.org> <CA+vVgJXh2PyeAT5LdWD6twijHPhmAoL9UPJxj+QJXvmey-WAgQ@mail.gmail.com>
Date Wed, 19 Sep 2012 08:22:27 -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.915.1348057739.27098.python-list@python.org> (permalink)
Lines 38
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1348057739 news.xs4all.nl 6895 [2001:888:2000:d::a6]:35041
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:29489

Show key headers only | View raw


On Wed, Sep 19, 2012 at 8:01 AM, Dwight Hutto <dwightdhutto@gmail.com> wrote:
>> 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?
>
This one is better:


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]
count = 0
collection_count = 0
search_variable = 1
for dict_key_search in x:
	if dict_key_search['dict'] == search_variable:
		print "Match count found: #%i = %i" % (count,search_variable)
		collection_count += 1
	count += 1
print collection_count

-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: A little morning puzzle Dwight Hutto <dwightdhutto@gmail.com> - 2012-09-19 08:22 -0400

csiph-web