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: | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
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 ответов
+ 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
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