I have tried to find an explanation but couldn't, so my apologies if this is a silly question.
Having data x:
x = [(1, {'gender': 'male'}),
(2, {'gender': 'female'}),
(3, {'gender': 'male'}),
(4, {'gender': 'female'}),
(5, {'gender': 'male'})]
...
A plausible solution for counting the occurrences of each gender would be:
from collections import Counter
Counter([d['gender'] for n, d in x)])
Returning:
Counter({'female':2, 'male':3})
Now I am trying to understand how "d['gender'] for n, d " works within "Counter([d['gender'] for n, d in x)]". What exactly is "n" in this case?
Many thanks for any pointers.