I'm trying to return the sum of the numbers in the array, returning 0 for an empty array. Except the number 13 it doesn't count and the number immediately after 13.
def sum13(nums):
p = 0
for i in range(len(nums)):
if nums[i] == 13 and nums[i + 1]:
continue
p += nums[i]
return p
When I run it, it gives me an index error list index our of range, what am I doing wrong?