Twos Add Up
This is a small list check where only the 2 values matter and all other numbers can be ignored. Write a function sum28 that takes a list nums and adds up all values equal to 2. Return True if the sum of those twos is exactly 8, otherwise return False.
Примеры
Ввод
[2, 3, 2, 2, 4, 2]Вывод
TrueВвод
[2, 3, 2, 2, 4, 2, 2]Вывод
FalseВвод
[1, 2, 3, 4]Вывод
FalseНужно реализовать
def sum28(nums: list[int]) -> bool:
Теги
listsarray
Idħol biex tara l-istorja tas-sottomissjonijiet
IdħolIdħol biex tuża l-Mentor tal-AI
IdħolVisible tests
1
Input
[2,3,2,2,4,2]Expected
True2
Input
[2,3,2,2,4,2,2]Expected
False3
Input
[1,2,3,4]Expected
False4
Input
[2,2,2,2]Expected
True5
Input
[]Expected
False6
Input
[2]Expected
FalseFocus radio
Paused · SomaFM · Fluid