Summing a 2D list

John Salerno johnjsal at NOSPAMgmail.com
Thu Jun 12 16:28:11 CEST 2008


"Mark" <markjturner at gmail.com> wrote in message 
news:c0461b8e-a60d-43f3-b0ab-6d2030dcd149 at 79g2000hsk.googlegroups.com...
On Jun 12, 3:02 pm, "Diez B. Roggisch" <de... at nospam.web.de> wrote:
> Mark wrote:

---
This was my (failed) attempt:

predictions = Prediction.objects.all()
scores = []
for prediction in predictions:
i = [prediction.predictor.id, 0]
if prediction.predictionscore:
i[1] += int(prediction.predictionscore)
scores.append(i)
---

Your question sounds like a fun little project, but can you post what the 
actual list of users/scores looks like? Is it a list of tuples like this:

[(1, 0), (1, 1) ... ]

Or something else?





More information about the Python-list mailing list