I have a list with individual dicts, like so:
dct = [{ 'winner': 'Person A' }, { 'winner': 'Person B' }, { 'winner': 'Person B' } ...]
(the dicts have other properties, they're just not relevant).
I want to know how many times the winner was a particular string. I could do something like this:
aWins = sum((1 if d['winner'] == 'Person A' else 0) for d in dct)
then do the same for 'Person B', and maybe possibly 'Person C' if that ever comes up, etc.
However, that doesn't strike me as particularly neat or pythonic. I'm still learning all the pythonic ways of doing things (I daily drive JS, so usually I'd be doing this via reduce), so is it possible to do this more neatly? Ideally, the output is a dict that looks something like this:
{ 'Person A': 40, 'Person B': 60 }