front_11

Given 2 int lists, a and b, of any length, return a new list with the first element of each list. If either list is length 0, ignore that 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]
[7, 9, 8]

Output:

[1, 7]

Test 2

Input:

[1]
[2]

Output:

[1, 2]

Test 3

Input:

[1, 7]
[]

Output:

[1]

Test 4

Input:

[]
[2, 8]

Output:

[2]

Test 5

Input:

[]
[]

Output:

[]

Test 6

Input:

[3]
[1, 4, 1, 9]

Output:

[3, 1]

Test 7

Input:

[1, 4, 1, 9]
[]

Output:

[1]