Peter Otten a écrit :
(snip)

> I don't think your code is ugly. Anyway, here are two more alternatives:
> 
> 
>>>>types = [0] * 3
>>>>dispatch = [0, 0, 2, 0, 1]
>>>>for value in [1, 1, 0, 4]: 
> ...     types[dispatch[value]] += 1
> ...
> 
>>>>types
> 
> [3, 1, 0]

I wonder why I'm still pretending to be a programmer

> 
> 
>>>>inflated = [0] * 5
>>>>groups = [[0, 1, 3], [4], [2]]
>>>>for value in [1, 1, 0, 4]: 
> ...     inflated[value] += 1
> ... 
>>>>[sum(inflated[i] for i in group) for group in groups]
> 
> [3, 1, 0]
> 

me-change-job-me-go-selling-pizzas :(

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to