Adding Specific Value to Nested Lists
<p>I'm having a comprehension issue on a specific problem. I have a preexisting nested list, and I want to match and append one value from a different list to the end of each nested list. A quick example of what I've tried, but where I'm stuck: </p>

<pre><code> initial_values = [["First", 1], ["Second", 2], ["Third", 3], ["Fourth", 4]]
other_values = [1,2,3,4]

for sublist in initial_values:
    for i in other_values:
        sublist.append(i)


print initial_values
</code></pre>

<p>This returns <code>[['First', 1, 1, 2, 3, 4], ['Second', 2, 1, 2, 3, 4], ['Third', 3, 1, 2, 3, 4], ['Fourth', 4, 1, 2, 3, 4]]</code></p>

<p>I want it it to ideally return <code>[['First', 1, 1], ['Second', 2, 2], ['Third', 3, 3], ['Fourth', 4, 4]]</code></p>

<p>If you want to use for loop you can try  </p>

<pre><code>initial_values = [["First", 1], ["Second", 2], ["Third", 3], ["Fourth", 4]]
other_values = [1,2,3,4]

for i in range(0,len(other_values)):
    initial_values[i].append(other_values[i])

print initial_values
</code></pre>

<p>output:<br>
<code>[['First', 1, 1], ['Second', 2, 2], ['Third', 3, 3], ['Fourth', 4, 4]]</code></p>

python list