How to update elements of a nested list in python?
<p>I'm iterating over a list of lists in python, and I want to change the date format for some of the elements of the nested list.  I tried:</p>

<pre><code>for dividend in dividend_data:
    for date in dividend[1], dividend[3], dividend[4], dividend[5]:
        date = datetime.strptime(date, '%m/%d/%Y').strftime("%Y-%m-%d")
</code></pre>

<p>but the "date" variable doesn't carry back to the original list elements.  I can do this by handling them individually:</p>

<pre><code>dividend[1] = datetime.strptime(dividend[1], '%m/%d/%Y').strftime("%Y-%m-%d")
dividend[3] = datetime.strptime(dividend[3], '%m/%d/%Y').strftime("%Y-%m-%d")
dividend[4] = datetime.strptime(dividend[4], '%m/%d/%Y').strftime("%Y-%m-%d")
dividend[5] = datetime.strptime(dividend[5], '%m/%d/%Y').strftime("%Y-%m-%d")
</code></pre>

<p>But, there must be a better way to handle this, right?</p>