I am still learning python, so I tried to convert a list of tuples to a list of dictionaries using a function:
 query_result= [(3, 'base-certificate', 8, 2022), (2, 'case-certificate', 8, 2022), (3, 'standard-certificate', 8, 2022)]
I wrote a function that looks like this:
 def convert_query_data_for_frontend(object, time):
            if time == "month":
                data = [
                    {
                        row[1]: row[0],
                        "date": [row[2], row[3]],
                    }
                    for row in object
                ]
                return data
The result of running this function was: convert_query_data_for_frontend(query_result, 'month')
[{'base-certificate': 3, 'date': [8, 2022]}, {'case-certificate': 2, 'date': [8, 2022]}, {'standard-certificate': 3, 'date': [8, 2022]}]
It is not yet the desired result should have only one date for different dates in this case the month could be september etc, instead it should return:
[{'base-certificate': 3, 'case-certificate': 2, 'standard-certificate': 3, 'date': [8, 2022]}]
I thought just looping over the object and defining the dict would give me the desired result but didnt please what can I add or do in this case?
 
    