Find One Two Three
In lists, you often search for a whole pattern, not just one value, such as a sequence of actions or a code combination. Write a function array123 that takes a list of numbers nums and returns True if the numbers 1, 2, and 3 appear next to each other in that exact order. If no such triple exists, return False.
Примеры
Ввод
[1, 1, 2, 3, 1]Вывод
TrueВвод
[1, 1, 2, 4, 1]Вывод
FalseВвод
[1, 1, 2, 1, 2, 3]Вывод
TrueНужно реализовать
def array123(nums: list[int]) -> bool:
Теги
listsarray
Logáil isteach chun stair na n-aighneachtaí a fheiceáil
Logáil isteachLogáil isteach chun an Meantóir IS a úsáid
Logáil isteachVisible tests
1
Input
[1,1,2,3,1]Expected
True2
Input
[1,1,2,4,1]Expected
False3
Input
[1,1,2,1,2,3]Expected
True4
Input
[1,2,3]Expected
True5
Input
[3,2,1]Expected
False6
Input
[1,1,2,1,2,3,1,1]Expected
TrueFocus radio
Paused · SomaFM · Fluid