I created a for loop that calculates the sum of a list with the exception of the integer 13 and the integer that comes after it. My loop works but I do not know why, can anyone help explain?
I have tried to print various parts of the loop to understand what it is doing. It successfully omits the 13 from the sum but I don't understand why the 2 is also getting skipped.
    nums = [5, 13, 2]
    def sum13(nums):
        i = 0
        for elem in nums:
            if elem != 13:
                i = i + elem
            else:
                nums.remove(elem)
        return i
 
     
     
    