Positive Count // Negative Sum
<p>A fairly easy problem, but I'm still practicing iterating over multiple variables with for loops. In the below, I seek to return a new list, where x is the count of positive numbers and y is the sum of negative numbers from an input array <code>arr.</code></p>

<p>If the input array is empty or null, I am to return an empty array. </p>

<p>Here's what I've got! </p>

<pre><code>def count_positives_sum_negatives(arr):
    return [] if not arr else [(count(x), sum(y)) for x, y in arr]
</code></pre>

<p>Currently receiving... </p>

<p>TypeError: 'int' object is not iterable</p>

<p>wim's way is good.  Numpy is good for these types of things too.  </p>

<pre><code>import numpy as np
arr = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -11, -12, -13, -14, -15])
print([arr[arr &gt;= 0].size, arr[arr &lt; 0].sum()])
&gt;&gt; [10, -65]
</code></pre>

python list-comprehension multiple-variable-return