only_14

Given a list of ints, return true if every element is a 1 or a 4.

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

Output:

True

Test 2

Input:

[1, 4, 2, 4]

Output:

False

Test 3

Input:

[1, 1]

Output:

True

Test 4

Input:

[4, 1]

Output:

True

Test 5

Input:

[2]

Output:

False

Test 6

Input:

[]

Output:

True

Test 7

Input:

[1, 4, 1, 3]

Output:

False

Test 8

Input:

[3, 1, 3]

Output:

False

Test 9

Input:

[1]

Output:

True

Test 10

Input:

[4]

Output:

True

Test 11

Input:

[3, 4]

Output:

False

Test 12

Input:

[1, 3, 4]

Output:

False

Test 13

Input:

[1, 1, 1]

Output:

True

Test 14

Input:

[1, 1, 1, 5]

Output:

False

Test 15

Input:

[4, 1, 4, 1]

Output:

True