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


Groups > comp.lang.python > #29956

Re: A little morning puzzle

References (4 earlier) <CA+vVgJVbkYc=O_fhkSNGPKwF80Jg6X7LTOvdQAJ_agoOQbLOVg@mail.gmail.com> <CALwzidn7ztCJup+kPTVwLFFJj-Hxg5EM0PFsryHzca1T9DA9Aw@mail.gmail.com> <5060CE37.8080409@stoneleaf.us> <CA+vVgJXsGE_yLkmNFVNBKZGdZK7cB5FD+j0u6skhxt4UZrJN3A@mail.gmail.com> <CALwzid=QxjfVtL7M8mWRg_k9qiNs+5-wP7d7B8vHss3qyGeiPw@mail.gmail.com>
Date 2012-09-24 19:13 -0400
Subject Re: A little morning puzzle
From Dwight Hutto <dwightdhutto@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.1239.1348528422.27098.python-list@python.org> (permalink)

Show all headers | View raw


The posted code produces neither a set nor any keys;
> it prints out the same predetermined non-key value multiple times.

This shows multiple dicts, with the same keys, and shows different
values, and some with the same, and that is, in my opinion what the OP
asked for:

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



The OP can jump in and tell me to alter the example, if they want to.




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

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


Thread

Re: A little morning puzzle Peter Otten <__peter__@web.de> - 2012-09-19 14:09 +0200
  Re: A little morning puzzle Tobiah <toby@tobiah.org> - 2012-09-20 09:28 -0700
    Re: A little morning puzzle Dwight Hutto <dwightdhutto@gmail.com> - 2012-09-22 23:44 -0400
      Re: A little morning puzzle alex23 <wuwei23@gmail.com> - 2012-09-23 20:46 -0700
        Re: A little morning puzzle Dwight Hutto <dwightdhutto@gmail.com> - 2012-09-24 17:22 -0400
        RE: A little morning puzzle "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-09-27 17:58 +0000
    Re: A little morning puzzle Ian Kelly <ian.g.kelly@gmail.com> - 2012-09-23 22:51 -0600
    Re: A little morning puzzle Ethan Furman <ethan@stoneleaf.us> - 2012-09-24 14:18 -0700
    Re: A little morning puzzle Dwight Hutto <dwightdhutto@gmail.com> - 2012-09-24 18:07 -0400
    Re: A little morning puzzle Ian Kelly <ian.g.kelly@gmail.com> - 2012-09-24 17:01 -0600
    Re: A little morning puzzle Dwight Hutto <dwightdhutto@gmail.com> - 2012-09-24 19:13 -0400

csiph-web