title: recursively remove adjacent duplicates in a list
body: <p>I looked up and found a close example, but the answer found in this link: <a href="https://stackoverflow.com/questions/3460161/remove-adjacent-duplicate-elements-from-a-list">Remove adjacent duplicate elements from a list</a>  won't run the test cases for this problem. So this is all I have so far:</p>
  
  <pre><code>def remove_dups(thelist):
      """Returns: a COPY of thelist with adjacent duplicates removed.
  
      Example: for thelist = [1,2,2,3,3,3,4,5,1,1,1],
      the answer is [1,2,3,4,5,1]
  
      Precondition: thelist is a list of ints"""
      i = 1
      if len(thelist) == 0:
          return []
      elif len(thelist) == 1:
          return thelist
      elif thelist[i] == thelist[i-1]:
          del thelist[i]
      return remove_dups(thelist[i:])
  
  
  def test_remove_dups():
      assert_equals([], remove_dups([]))
      assert_equals([3], remove_dups([3,3]))
      assert_equals([4], remove_dups([4]))
      assert_equals([5], remove_dups([5, 5]))
      assert_equals([1,2,3,4,5,1], remove_dups([1,2,2,3,3,3,4,5,1,1,1]))
  
  # test for whether the code is really returning a copy of the original list
      mylist = [3]
      assert_equals(False, mylist is remove_dups(mylist))
  </code></pre>
  
  <p>EDIT while I do understand that the accepted answer linked above using itertools.groupby would work, I think it wouldn't teach me what's wrong with my code &amp; and would defeat the purpose of the exercise if I imported grouby from itertools. </p>