Re: A little morning puzzle

Discussion in 'Python' started by Dwight Hutto, Sep 19, 2012.

  1. Dwight Hutto

    Dwight Hutto Guest

    On Wed, Sep 19, 2012 at 8:01 AM, Dwight Hutto <> 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
    Dwight Hutto, Sep 19, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Neal Becker

    A little morning puzzle

    Neal Becker, Sep 19, 2012, in forum: Python
    Replies:
    2
    Views:
    158
    Paul Rubin
    Sep 19, 2012
  2. Peter Otten

    Re: A little morning puzzle

    Peter Otten, Sep 19, 2012, in forum: Python
    Replies:
    0
    Views:
    157
    Peter Otten
    Sep 19, 2012
  3. Dwight Hutto

    Re: A little morning puzzle

    Dwight Hutto, Sep 19, 2012, in forum: Python
    Replies:
    0
    Views:
    133
    Dwight Hutto
    Sep 19, 2012
  4. Peter Otten

    Re: A little morning puzzle

    Peter Otten, Sep 19, 2012, in forum: Python
    Replies:
    9
    Views:
    147
    Prasad, Ramit
    Sep 27, 2012
  5. Antoon Pardon

    Re: A little morning puzzle

    Antoon Pardon, Sep 19, 2012, in forum: Python
    Replies:
    0
    Views:
    147
    Antoon Pardon
    Sep 19, 2012
Loading...

Share This Page