Six on the Edge
Sometimes it is enough to check only the edges of a list instead of every value inside it. Write a function first_last6 that takes a non-empty list of numbers nums. Return True if the first or last element is 6; otherwise, return False.
Примеры
Ввод
[1, 2, 6]Вывод
TrueВвод
[6, 1, 2, 3]Вывод
TrueВвод
[13, 6, 1, 2, 3]Вывод
FalseНужно реализовать
def first_last6(nums: list[int]) -> bool:
Теги
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,6]Expected
True2
Input
[6,1,2,3]Expected
True3
Input
[13,6,1,2,3]Expected
False4
Input
[6]Expected
True5
Input
[5]Expected
False6
Input
[0,0,0]Expected
FalseFocus radio
Paused · SomaFM · Fluid