Python list of lists to divide an element position on all sublists by a number
<p>How can in python take a lists of lists and apply a division to the third element of each sublist.</p>

<p>The sublists looks like this </p>

<pre><code>[1.3735876284e-05, 0.9277849431216683, 34.02875434027778, 0.0]
[2.60440773e-06,   7.35174234e-01,   2.79259180e+02,   0.00000000e+00]
...
</code></pre>

<p>I need to get the same sublists but the third element of each sublist (34.02 ..., 2.79 ...) should be divided by 100</p>

<p>You could try this:</p>

<pre><code>a = [
    [1.3735876284e-05, 0.9277849431216683, 34.02875434027778, 0.0],
    [2.60440773e-06,   7.35174234e-01,   2.79259180e+02,   0.00000000e+00],
]
b = [
    [(x / 100.0 if i == 2 else x) for (i, x) in enumerate(lst)] 
        for lst in a
]
</code></pre>

<p>Or the lambda version:</p>

<pre><code>f = lambda a: [
    [(x / 100.0 if i == 2 else x) for (i, x) in enumerate(lst)] 
        for lst in a
]
b = f(a)
</code></pre>

python list