Nine at the Start

Sometimes only the beginning of a list matters, such as the first search results or a user’s first actions. Write a function array_front9 that takes a list of numbers nums and returns True if 9 appears among the first four elements. If the list has fewer than four elements, check only the elements that exist.

Примеры

Ввод
[1, 2, 9, 3, 4]
Вывод
True
Ввод
[1, 2, 3, 4, 9]
Вывод
False
Ввод
[1, 2, 3, 4, 5]
Вывод
False

Нужно реализовать

def array_front9(nums: list[int]) -> bool:

Теги

listsarray
PostgreSQLv16

Aquí aparecerá el resultado de la ejecución del código

Visible tests
1
Input
[1,2,9,3,4]
ExpectedTrue
2
Input
[1,2,3,4,9]
ExpectedFalse
3
Input
[1,2,3,4,5]
ExpectedFalse
4
Input
[9]
ExpectedTrue
5
Input
[]
ExpectedFalse
6
Input
[1]
ExpectedFalse
Focus radio
Paused · SomaFM · Fluid