title: Python comparing two uneven arrays
body: <p>I am trying to generate two arrays, <code>a</code> and <code>b</code>, each containing ~1000 random numbers. The random number are between 1 and 5. </p>
  
  <p>I want to then compare each element in <code>a</code> with the corresponding element of <code>b</code> such that if <code>a[i] &gt; b[i]</code> a variable, <code>counter</code>, will be incremented by 1. This is considered a "success". Otherwise, if <code>a[i] &lt;= b[i]</code> nothing happens (i.e <code>counter += 0</code>). This is considered a "fail".</p>
  
  <p>However, <code>a</code> and <code>b</code> can be of variable length such that both <code>len(a) == len(b)</code> and <code>len(a) != len(b)</code> are possibilities.</p>
  
  <p>In the case of the latter, if <code>len(a) &gt; len(b)</code> I'd like all the "extra" elements of <code>a</code> to automatically be counted as "successes". If <code>len(b) &gt; len(a)</code> things should proceed normally (i.e the "extra" elements of <code>b</code> are ignored).</p>
  
  <p>For example:</p>
  
  <p>If <code>a = [1, 3, 4, 2]</code> and <code>b = [2, 4, 0]</code></p>
  
  <p>Then <code>counter = 2</code> because (<code>1 &lt; 2</code>, <code>3 &lt; 4</code>, <code>4 &gt; 0</code>, and <code>2</code> is extra and is an automatic success`)</p>
  
  <p>How would I go about doing this?  </p>
  
  <p>Here is some quick code, which returns the expected <code>list index out of range...</code> error:</p>
  
  <pre><code>import random
  
  a = []
  b = []
  counter = 0
  
  for i in range(1000):
      a += [random.randint(1, 5)]
  for i in range(900):
      b += [random.randint(1, 5)]
  for i in range(len(a)):
      if a[i] &gt; b[i]:
          counter += 1
  
  print counter
  </code></pre>