title: Python loop to calculate sum of elements in a list except 13
body: <p>I am trying to write a function that iterates through a list to return the sum of the integer elements in the list. However if there is a 13 in the list, it needs to exclude the 13 and whatever comes right after it from the sum. So far I have come up with the following code. This works for almost all cases except when there are two 13's back to back. It only excludes the two 13's instead of the two 13's plus whatever is after the second 13. For example, when I call the function with <code>print(sum13([13, 13, 2, 13, 1, 5, 6, 13]))</code>, instead of giving the output of <code>11</code> it gives <code>13</code>. Any help is appreciated.</p>
  
  <pre><code>    def sum13(nums):
  
        while 13 in nums:
            index13 = nums.index(13)
            nums = nums[0:index13]+nums[index13+2:]
        return sum(nums)
  </code></pre>