I'm getting confused with this question at what it's trying to ask.
Write function
mssl()(minimum sum sublist) that takes as input a list of integers. It then computes and returns the sum of the maximum sum sublist of the input list. The maximum sum sublist is a sublist (slice) of the input list whose sum of entries is largest. The empty sublist is defined to have sum 0. For example, the maximum sum sublist of the list[4, -2, -8, 5, -2, 7, 7, 2, -6, 5]is[5, -2, 7, 7, 2]and the sum of its entries is19.
If I were to use this function it should return something similar to
>>> l = [4, -2, -8, 5, -2, 7, 7, 2, -6, 5]
>>> mssl(l)
19
>>> mssl([3,4,5])
12
>>> mssl([-2,-3,-5])
0
How can I do it?
Here is my current try, but it doesn't produce the expected result:
def mssl(x):
' list ==> int '
res = 0
for a in x:
if a >= 0:
res = sum(x)
return res
else:
return 0