A little morning puzzle

Ian Kelly ian.g.kelly at gmail.com
Mon Sep 24 19:01:04 EDT 2012


On Mon, Sep 24, 2012 at 4:07 PM, Dwight Hutto <dwightdhutto at gmail.com> wrote:
> They stated:
>
> 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?
>
> No, to me it meant to find similar values in several dicts with the
> same key, and value. So I created several dicts, and some with the
> same key and value, and showed the matches.

Well, to me at least it is clear that when the OP writes "I want to
find the *set* of *keys*..." (emphasis added), then setting aside the
rest of the problem statement, the result of the algorithm should be a
set (or at least something set-like), and the contents of the set
should be keys.  The posted code produces neither a set nor any keys;
it prints out the same predetermined non-key value multiple times.



More information about the Python-list mailing list