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>Simply use a <code>sum</code> comprehension</p>

<pre><code>&gt;&gt;&gt; arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -11, -12, -13, -14, -15]
&gt;&gt;&gt; sum(1 for x in arr if x &gt; 0)
10
&gt;&gt;&gt; sum(x for x in arr if x &lt; 0)
-65
</code></pre>

python list-comprehension multiple-variable-return