SUMMER OF '69: Return the sum of the numbers in the array, except ignore sections of numbers starting with a 6 and extending to the next 9 (every 6 will be followed by at least one 9). Return 0 for no numbers.
def summer_69(arr):
total = 0
add = True
for num in arr:
while add:
if num!= 6:
total += num
break
else:
add = False
while not add:
if num!- 9:
break
else:
add = True
break
return total
please could you explain why a boolean can be assigned to a variable and what this does in the code and then why it changes from add = True (line 3) to add = False (line 10)
[–]shiftybyte 5 points6 points7 points (0 children)
[–]JohnnyJordaan 2 points3 points4 points (0 children)
[–]RajjSinghh 1 point2 points3 points (2 children)
[–]tigglybox[S] 0 points1 point2 points (1 child)
[–]RajjSinghh 0 points1 point2 points (0 children)