title: Initialize the first index of a list in Python
body: <p>I am converting something I wrote in C++ to Python. Here is a snippet of what I am trying to rewrite in python:</p>
  
  <pre><code>std::vector&lt;int&gt; dates(numberOfPayments.size(), 0);
  dates[0] = NDD[0] - '0';
  for (int i = 1; i &lt; dates.size(); ++i)
  {
      dates[i] = (dates[i - 1] + 12 - numberOfPayments[i - 1]) % 12;
  }
  </code></pre>
  
  <p>The problem I am having is that I cannot set the first index of my list in python to something. I try this:</p>
  
  <pre><code>dates = []
  dates[0] = NDD_month[0]
  for i in range(len(first_payments)):
      dates[i] = (dates[i-1] + 12 - first_payments[i-1]) % 12
  print(dates)
  </code></pre>
  
  <p>But I get this error:</p>
  
  <pre><code>IndexError: list assignment index out of range
  </code></pre>
  
  <p>Anyone know how to fix this?</p>