sum_13

Return the sum of the numbers in the list, returning 0 for an empty list. Except the number 13 is very unlucky, so it does not count and numbers that come immediately after a 13 also do not count.

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, 1]

Output:

6

Test 2

Input:

[1, 1]

Output:

2

Test 3

Input:

[1, 2, 2, 1, 13]

Output:

6

Test 4

Input:

[1, 2, 13, 2, 1, 13]

Output:

4

Test 5

Input:

[13, 1, 2, 13, 2, 1, 13]

Output:

3

Test 6

Input:

[]

Output:

0

Test 7

Input:

[13]

Output:

0

Test 8

Input:

[13, 13]

Output:

0

Test 9

Input:

[13, 0, 13]

Output:

0

Test 10

Input:

[13, 1, 13]

Output:

0

Test 11

Input:

[5, 7, 2]

Output:

14

Test 12

Input:

[5, 13, 2]

Output:

5

Test 13

Input:

[0]

Output:

0

Test 14

Input:

[13, 0]

Output:

0