mod_three

Given a list of ints, return true if the list contains either 3 even or 3 odd values all next to each other.

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:

[2, 1, 3, 5]

Output:

True

Test 2

Input:

[2, 1, 2, 5]

Output:

False

Test 3

Input:

[2, 4, 2, 5]

Output:

True

Test 4

Input:

[1, 2, 1, 2, 1]

Output:

False

Test 5

Input:

[9, 9, 9]

Output:

True

Test 6

Input:

[1, 2, 1]

Output:

False

Test 7

Input:

[1, 2]

Output:

False

Test 8

Input:

[1]

Output:

False

Test 9

Input:

[]

Output:

False

Test 10

Input:

[9, 7, 2, 9]

Output:

False

Test 11

Input:

[9, 7, 2, 9, 2, 2]

Output:

False

Test 12

Input:

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

Output:

True