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
PostgreSQLv16

Tady se objeví výsledek běhu kódu

Visible tests
1
Input
[2,3,2,2,4,2]
ExpectedTrue
2
Input
[2,3,2,2,4,2,2]
ExpectedFalse
3
Input
[1,2,3,4]
ExpectedFalse
4
Input
[2,2,2,2]
ExpectedTrue
5
Input
[]
ExpectedFalse
6
Input
[2]
ExpectedFalse
Focus radio
Paused · SomaFM · Fluid