Double Two or Three
With very short lists, it is often easier to check the needed values directly instead of building a complex algorithm. Write a function double23 that takes a list nums containing 0, 1, or 2 numbers. Return True if the list contains exactly two 2 values or exactly two 3 values; otherwise, return False.
Примеры
Ввод
[2, 2]Вывод
TrueВвод
[3, 3]Вывод
TrueВвод
[2, 3]Вывод
FalseНужно реализовать
def double23(nums: list[int]) -> bool:
Теги
listsarray
Συνδεθείτε για να δείτε το ιστορικό υποβολών
ΣύνδεσηΣυνδεθείτε για να χρησιμοποιήσετε τον AI Mentor
ΣύνδεσηVisible tests
1
Input
[2,2]Expected
True2
Input
[3,3]Expected
True3
Input
[2,3]Expected
False4
Input
[2]Expected
False5
Input
[]Expected
False6
Input
[3,4]Expected
FalseFocus radio
Paused · SomaFM · Fluid