I have a list of tuples, each tuple has patient and visit, patient can have several visits
I want to get list of patient and for every patient the list of their visits
for example
[(patient1, visit), (patient2, visit), (patient1, visit)]
To
[(patient1, [visit, visit]), (patient2, [visit])]
I tried javascript's reduce
function approach, but I can't really understand how I can do it in python