Available Front Values
This function helps you practice checking for empty lists before trying to read an element. Write a function front11 that takes two lists a and b, each with length 0 or 1. Return a new list containing the first element of each list, but only if that element exists.
Примеры
Ввод
[1], [2]Вывод
[1, 2]Ввод
[1], []Вывод
[1]Ввод
[], [2]Вывод
[2]Нужно реализовать
def front11(a: list[int], b: list[int]) -> list[int]:
Теги
listsarray
Conectează-te pentru a vedea istoricul soluțiilor trimise
Conectează-teConectează-te pentru a folosi Mentorul AI
Conectează-teVisible tests
1
Input
[1], [2]Expected
[1,2]2
Input
[1], []Expected
[1]3
Input
[], [2]Expected
[2]4
Input
[], []Expected
[]5
Input
[2], [2,2]Expected
[2,2]6
Input
[1], [0]Expected
[1,0]Focus radio
Paused · SomaFM · Fluid