same_first_last

Given a list of ints, return true if the list is length 1 or more, and the first element and the last element are equal.

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]

Output:

False

Test 2

Input:

[1, 2, 3, 1]

Output:

True

Test 3

Input:

[1, 2, 1]

Output:

True

Test 4

Input:

[7]

Output:

True

Test 5

Input:

[]

Output:

False

Test 6

Input:

[1, 2, 3, 4, 5, 1]

Output:

True

Test 7

Input:

[1, 2, 3, 4, 5, 13]

Output:

False

Test 8

Input:

[13, 2, 3, 4, 5, 13]

Output:

True

Test 9

Input:

[7, 7]

Output:

True