shift_left

Return a list that is “left shifted” by one – so {6, 2, 5, 3} returns {2, 5, 3, 6}. You may modify and return the given list, or return a new 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:

[6, 2, 5, 3]

Output:

[2, 5, 3, 6]

Test 2

Input:

[1, 2]

Output:

[2, 1]

Test 3

Input:

[1]

Output:

[1]

Test 4

Input:

[]

Output:

[]

Test 5

Input:

[1, 1, 2, 2, 4]

Output:

[1, 2, 2, 4, 1]

Test 6

Input:

[1, 1, 1]

Output:

[1, 1, 1]

Test 7

Input:

[1, 2, 3]

Output:

[2, 3, 1]