silverburgh: > max([(sum(a[j:i]), (j,i)) Other people have already answered you so I'll add only a small note: today the max() function has a key optional attribute, so that code can also be written as:
max(((j, i) for ...), key=lambda (j, i): sum(a[j : i])) I think you have copied that part from code that runs in O(n^2); remember that you can find the max subarray with a well known O(n) algorithm too. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list