def summer_of69(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
In this code, if I pass summer_of69([2,5,6,9,11])
, how 9 is getting ignored and 11 getting added?
The output I am getting 18 is correct but I want to know how 2nd while loop is working here.
After 6 how is it working for 9 and 11?