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
Log ind for at se indsendelseshistorik
Log indLog ind for at bruge AI-mentor
Log indVisible tests
1
Input
[1,2,9,3,4]Expected
True2
Input
[1,2,3,4,9]Expected
False3
Input
[1,2,3,4,5]Expected
False4
Input
[9]Expected
True5
Input
[]Expected
False6
Input
[1]Expected
FalseFocus radio
Paused · SomaFM · Fluid