common_end

Given 2 lists of ints, a and b, return true if they have the same first element or they have the same last element. Both lists will be length 1 or more.

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

Output:

True

Test 2

Input:

[1, 2, 3]
[7, 3, 2]

Output:

False

Test 3

Input:

[1, 2, 3]
[1, 3]

Output:

True

Test 4

Input:

[1, 2, 3]
[1]

Output:

True

Test 5

Input:

[1, 2, 3]
[2]

Output:

False