title: Python list dimension size error
body: <p>Consider the following code in python:  </p>
  
  <pre><code>def main():
      n = input( )
      s = input( )
  
      coins = [ 0 ]*n
      dp = [ 0 ]*( s+1 )
  
      print coins
      print dp
  
      for i in range( n ) :
          coins[ i ] = input( )
  
      dp[ 0 ]=0
      dp[ 1 ]=1
  
      for i in range( 2, s+1 ) :
          min_val = 999999
          for j in range( 0, n ) :
              if i-coins[ j ] &gt; 0 :
                  if dp[ i-coins[ j ] ] + 1 &lt; min_val :
                      min_val = dp[ i-coins[ j ] ] + 1
  
  
      print coins
      print dp
  
      print coins[ s ]
  
  if __name__ == "__main__" :
      main()
  </code></pre>
  
  <p>When I compile and run this program, I get the following runtime error:</p>
  
  <pre><code>File "test.py", line 33, in &lt;module&gt;
    main();
  File "test.py", line 30 in main
    if dp[ i-coins[ j ] ] + 1 &lt; min_val :
  
  IndexError: list index out of range
  </code></pre>
  
  <p>What's wrong with it?</p>
  
  <p>Input:</p>
  
  <pre><code>5 10
  1 3 5 7 9
  </code></pre>