Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: A little morning puzzle

Reply
Thread Tools

Re: A little morning puzzle

 
 
Peter Otten
Guest
Posts: n/a
 
      09-19-2012
Neal Becker 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?

>>> items = [

.... {1:2, 2:2},
.... {1:1, 2:2},
.... ]
>>> first = items[0].items()
>>> [key for key, value in first if all(item[key] == value for item in

items)]
[2]


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: A little morning puzzle Peter Otten Python 9 09-27-2012 05:58 PM
A little morning puzzle Neal Becker Python 2 09-19-2012 05:12 PM
Re: A little morning puzzle Dwight Hutto Python 0 09-19-2012 12:22 PM
Re: A little morning puzzle Antoon Pardon Python 0 09-19-2012 12:13 PM
Re: A little morning puzzle Dwight Hutto Python 0 09-19-2012 12:01 PM



Advertisments