68 758
Assignments Done
Successfully Done
In January 2019

Answer to Question #62122 in Python for Tijjani Ayuba

Question #62122
Write a function called manipulate_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.

NB: Treat 0 as positive.
Expert's answer
def manipulate_data(data):
pos, neg = 0, 0
for x in data:
if x >= 0: pos += 1
else: neg += x
return [pos, neg]

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions