"Gabriel Genellina" <gagsl-...@yahoo.com.ar> writes: > > for x in population: > > f = fitness(x) > > fap += [(f, x)] > > total += f > > return sorted(fap, reverse=True), total > ... > Environmentally friendly Pythoneers avoid using discardable > intermediate envelopes: > > fap.append((f, x))
I'd probably use: fap = list((fitness(x),x) for x in population) total = sum(x for x,y in fap) return sorted(fap, reverse=True), total -- http://mail.python.org/mailman/listinfo/python-list