title: Number of times a number has changed in excel column
body: <p>I just started learning Python and need help analyzing data in an excel spreadsheet. The excel sheet has i.e. 111122221112211 in one column and I'm trying to figure out how many changes from 1 to 2 or 2 to 1 occur here. In this case, 4 times. </p>
  
  <p>I've been told to use set.difference but I don't understand how. So I tried my own way and get the error 'list index out of range' at the elif part. Here is my script (I'm still working on the basics so this may seem very amateur):</p>
  
  <pre><code>a = xlws.Columns(5).value
  a = [list(x)[0] for x in a[1:400]]
  
  beam = 0
  
  for x in range(len(a)):
      if a[x] ==1 and a[x+1]==2:
          beam += 1
      elif  a[x]==2 and a[x+1]==1:
          beam += 1
      else: 
          beam = beam 
  </code></pre>