I am executing the following sqlite command:
c.execute("SELECT surname,forename,count(*) from census_data group by surname, forename")
so that c.fetchall() is as follows:
(('Griffin','John', 7),
('Griffin','James', 23),
('Griffin','Mary',30),
('Griffith', 'John', 4),
('Griffith','Catherine', 5)
)
Is it possible to construct a dict of the following form using a dict comprehension:
{'Griffin': {'John': 7, 'James': 23, 'Mary':30}, 'Griffith': {'John':4,'Catherine':5}}
this is as far as I got:
counts = {s:(f,c) for s,f,c in c.fetchall()}
which overwrites values. Im using python 3.