0

def manipulate_data(n): positives,negatives=[],[] if not isinstance(n,list): raise ValueError return else: for i in n: if i>=0: positives.append(i) if i<0 negatives.append(i) new=[len(positives,sum(negatives)] return new. Someone kindly assist I keep running it in unitests and I keep getting errors. Here's the question:

data structures

10th Sep 2016, 2:29 PM
brian
2 Answers
+ 1
http://code.sololearn.com/cruBN2hCo7Hv def manipulate_data(n: list) -> list: if not isinstance(n,list): raise TypeError countPos, sumNeg = 0, 0 for i in n: if i>=0: countPos += 1 else: sumNeg += i return [countPos, sumNeg] print(manipulate_data([1, 3, -5, -2, 6, -1]))
14th Sep 2016, 10:38 AM
Zen
Zen - avatar
0
Here's the question: Write a function called manipulated_dataĀ which will act as follows: When given aĀ list of integers, return aĀ list, where theĀ first element is the count of positives numbersĀ and the second element is the sum of negative numbers.
10th Sep 2016, 2:30 PM
brian