an error in commented code?
John Salerno
johnjsal at NOSPAMgmail.com
Fri Apr 28 17:29:37 EDT 2006
Gerard Flanagan wrote:
> I don't think you need all those 'ifs'.
>
> groups = [group1, group2, group3, group4]
>
> def checkOrder(x, y):
> x_votes = 0
> y_votes = 0
> for group in groups:
> if group.index(x) < group.index(y):
> x_votes += group[4]
> else:
> y_votes += group[4]
>
> for order in all_perms(props):
> winner = reduce(checkOrder, order)
> print '%s wins!' % winner
> print order
>
Nice. I was shuddering as I copy and pasted each if block. :)
More information about the Python-list
mailing list