title: Decrement the Variable I'm Incrementing in for loop
body: <p>kind of a newbie to Python and I've looked around a bit but haven't found a satisfying answer to my question. I'm doing some practice problems and I want to make a method that gets rid of duplicate values in a list. So far, this is my code:</p>
  
  <pre><code>def noDouble(nums):
    for x in xrange(len(nums) - 2):
        if nums[x] == nums[x + 1]:
            nums.pop(x)
            x -= 1
    return nums
  </code></pre>
  
  <p>What I want to happen is that if there's a duplicate, pop off one of the duplicates and then move back again (so that if there are, say, 3 instances of the same number, it'll get rid of al of them by 'rewinding').</p>
  
  <p>I'm looking for an explanation for why my code doesn't work as well as an explained solution and I'd really appreciate any and all help. Thanks.</p>