has_12

Given a list of ints, return true if there is a 1 in the list with a 2 somewhere later in the list.

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, 3, 2]

Output:

True

Test 2

Input:

[3, 1, 2]

Output:

True

Test 3

Input:

[3, 1, 4, 5, 2]

Output:

True

Test 4

Input:

[3, 1, 4, 5, 6]

Output:

False

Test 5

Input:

[3, 1, 4, 1, 6, 2]

Output:

True

Test 6

Input:

[2, 1, 4, 1, 6, 2]

Output:

True

Test 7

Input:

[2, 1, 4, 1, 6]

Output:

False

Test 8

Input:

[1]

Output:

False

Test 9

Input:

[2, 1, 3]

Output:

False

Test 10

Input:

[2, 1, 3, 2]

Output:

True

Test 11

Input:

[2]

Output:

False

Test 12

Input:

[3, 2]

Output:

False

Test 13

Input:

[3, 1, 3, 2]

Output:

True

Test 14

Input:

[3, 5, 9]

Output:

False

Test 15

Input:

[3, 5, 1]

Output:

False

Test 16

Input:

[3, 2, 1]

Output:

False

Test 17

Input:

[1, 2]

Output:

True