sum_67

Return the sum of the numbers in the list, 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.

This exercise was taken from codingbat.com and has been adapted for the Python language. There are many great programming exercises there, but the majority are created for Java.

Test 1

Input:

[1, 2, 2]

Output:

5

Test 2

Input:

[1, 2, 2, 6, 99, 99, 7]

Output:

5

Test 3

Input:

[1, 1, 6, 7, 2]

Output:

4

Test 4

Input:

[1, 6, 2, 2, 7, 1, 6, 99, 99, 7]

Output:

2

Test 5

Input:

[1, 6, 2, 6, 2, 7, 1, 6, 99, 99, 7]

Output:

2

Test 6

Input:

[2, 7, 6, 2, 6, 7, 2, 7]

Output:

18

Test 7

Input:

[2, 7, 6, 2, 6, 2, 7]

Output:

9

Test 8

Input:

[1, 6, 7, 7]

Output:

8

Test 9

Input:

[6, 7, 1, 6, 7, 7]

Output:

8

Test 10

Input:

[6, 8, 1, 6, 7]

Output:

0

Test 11

Input:

[]

Output:

0

Test 12

Input:

[6, 7, 11]

Output:

11

Test 13

Input:

[11, 6, 7, 11]

Output:

22

Test 14

Input:

[2, 2, 6, 7, 7]

Output:

11