Need help multiplying positive numbers in a list by 3, and leaving other numbers unmodified
<p>My goal is to multiply all positive numbers in a list by 3. I think I've almost got the solution but I'm not sure what is causing it not to work. It currently just returns back the original numbers and does not multiply any numbers by 3.</p>

<pre><code>def triple_positives(xs):
    List = []
    product = 3
    for i in range (len(List)):
        if List[i] &gt;= 0:
            product *= i
        List.append(xs[i])
    return xs
</code></pre>

<p>Modifying your function it should be something like this.
0 is not a positive number.So using > instead of >=.</p>

<pre><code>def triple_positives(xs):
    List = []
    product = 3
    for i in xs:
        if i &gt; 0:
            i=i*product
        List.append(i)
    return List
</code></pre>

<p>But this can be done like this also</p>

<pre><code>def triple_positives(xs):
    return [3*i if i&gt;0 else i for i in xs  ]
</code></pre>

python list numbers multiplying