title: Starting with Python - Hamming distance of a list of strings
body: <p>I'm new in Python and I'm trying to obtain the Hamming distance between a pair of DNA sequences. Although I was able to do this, I don't really know how to obtain a list of Hamming distances of more than one pair of DNA sequences. I wonder if anyone could please guide me on this.</p>
  <pre><code>dna1 = 'ACCTAT'
  dna2 = 'CATTGA'
  
  def distance(strand_a, strand_b):
      if len(strand_a) == len(strand_b):
          i = 0
          n = 0
          while i &lt; len(strand_a):
              if strand_a[i] != strand_b[i]:
                  i += 1
                  n += 1
              else:
                  i += 1
          return(n)
      else:
          raise ValueError(&quot;The strings are not the same length&quot;)
  </code></pre>
  <p>Output:</p>
  <pre><code>The distance is: 5
  </code></pre>
  <p>I wonder if anyone could please help me know which could be the best way to obtain a list of Hamming distances between three pairs of DNA sequences (I tried to do this myself by changing the code above, but I haven't been able to find the solution).</p>
  <p>Given these two lists, I want to get the Hamming distance between the 1st, 2nd and 3rd pairs of DNA sequences:</p>
  <pre><code>dna1 = ['ACTGG','ATGCA','AACTG']
  dna2 = ['ACTGA','ATGGG','ATGAC']
  </code></pre>
  <p>Where the output would be:</p>
  <pre><code>distances = [1, 2, 4]
  </code></pre>
  <p>Thank you all for your help!</p>