data = [
{'event' : 'test', 'values': {'English':'Pass','Spanish':'Yes','French':'Love'}},
{'event' : 'exam', 'values': {'English':'Fail','Spanish':'Yes','French':'Hate'}},
{'event' : 'test', 'values': {'English':'Pass','Spanish':'No','French':'Love'}},
{'event' : 'test', 'values': {'English':'Fail','Spanish':'Yes','French':'Hate'}},
{'event' : 'exam', 'values': {'English':'Pass','Spanish':'Yes','French':'Love'}},
{'event' : 'test', 'values': {'English':'Pass','Spanish':'Yes','French':'Love'}},
{'event' : 'exam', 'values': {'English':'Pass','Spanish':'Yes','French':'Love'}},
{'event' : 'test', 'values': {'English':'Pass','Spanish':'No','French':'Hate'}},
{'event' : 'exam', 'values': {'English':'Fail','Spanish':'Yes','French':'Love'}},
{'event' : 'test', 'values': {'English':'Pass','Spanish':'Yes','French':'Hate'}}
]
Can somebody implement the function call(data,'test',['English','Spanish','French']') where the function type of call is :
call(List input, String Name,List groups)
Here data array is converted to objects of Exam Type and has getters for each key.
The main challenge here is to output the data in the following format:
Here the groups list is dynamic i.e for now it is ['English','Spanish','French'] but it can increase to ['English','Spanish','French','German'].
can anyone generate this dynamic dictionary?
'test':{
'values':6,
'English':{
Pass:'5',
Fail:'1'
},
'Spanish':{
Yes:'4',
No:'2'
}
'French':{
Love:'3',
Hate:'3'
}
}