I only started coding about a month ago and I am currently having a problem with this question:
"Return the sum of the numbers in the array, except ignore sections of numbers starting with a 6 and extending to the next 7 (every 6 will be followed by at least one 7). Return 0 for no numbers."
My attempt is the following:
def sum67(nums):
    summe=0
    
    if 6 not in nums:
        for elem in nums:
            summe+= elem
    else:
      indexof_6= nums.index(6)
      indexof_7= nums.index(7)
      copynums= nums[:]
      del(copynums[(indexof_6) : (indexof_7+1)])
      for i in copynums: 
          summe+= i
    return summe
unfortunately it only returns correct values for lists like [2,3,4,6,7,9] where only one 6 is present. Whereas it returns wrong values when there is more than one 6 e.g. [5,6,10,7, 5,6,9,7,1].
I already tried looking for different solutions online but i don't seem to understand them ... is my attempt with ".index()" wrong? can this one only catch the first index of a "6" ?
I would be extremely grateful for a few hints on how to correct myself :) thanks so much in advance! kind regards
 
     
     
    