max_end_3

Given a list of ints length 3, figure out which is larger, the first or last element in the list, and set all the other elements to be that value. Return the changed 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, 2, 3]

Output:

[3, 3, 3]

Test 2

Input:

[11, 5, 9]

Output:

[11, 11, 11]

Test 3

Input:

[2, 11, 3]

Output:

[3, 3, 3]

Test 4

Input:

[11, 3, 3]

Output:

[11, 11, 11]

Test 5

Input:

[3, 11, 11]

Output:

[11, 11, 11]

Test 6

Input:

[2, 2, 2]

Output:

[2, 2, 2]

Test 7

Input:

[2, 11, 2]

Output:

[2, 2, 2]

Test 8

Input:

[0, 0, 1]

Output:

[1, 1, 1]