fork download
  1. llist = [{'a':'foo', 'b':'bar', 'c':1}, {'a':'foo', 'b':'bar', 'c':2}, {'a':'foo', 'b':'bar', 'c':3}, {'a':'hui', 'b':'pizda', 'c':1}, {'a':'hui', 'b':'pizda', 'c':2}]
  2. lnew = {}
  3. for n in llist:
  4. for k, v in n.items():
  5. if k in lnew:
  6. lnew[k].add(v)
  7. else:
  8. lnew[k] = {v}
  9. print(lnew)
Success #stdin #stdout 0.02s 9160KB
stdin
Standard input is empty
stdout
{'a': {'foo', 'hui'}, 'b': {'pizda', 'bar'}, 'c': {1, 2, 3}}