Double Two
Sometimes you need to notice not just a value in a list, but the same value appearing twice in a row. Write a function has22 that takes a list nums and checks whether it contains two neighboring 2 values. Return True if such a pair is found, otherwise return False.
Примеры
Ввод
[1, 2, 2]Вывод
TrueВвод
[1, 2, 1, 2]Вывод
FalseВвод
[2, 1, 2]Вывод
FalseНужно реализовать
def has22(nums: list[int]) -> bool:
Теги
listsarray
Logga in för att se historik över inskick
Logga inLogga in för att använda AI-mentorn
Logga inVisible tests
1
Input
[1,2,2]Expected
True2
Input
[1,2,1,2]Expected
False3
Input
[2,1,2]Expected
False4
Input
[2,2,1,2]Expected
True5
Input
[]Expected
False6
Input
[2,2]Expected
TrueFocus radio
Paused · SomaFM · Fluid