Skip to content
Advertisement

How to ignore numbers after specific number in the list/array in Python?

I’m stuck on this problem:

I was trying to return sum of list of numbers in the array ignoring 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.

Here are my test cases:

JavaScript

I came up with something like:

JavaScript

Advertisement

Answer

i guess we stop adding when we see 6 and we start again when we see 9

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement