Add Numbers in Text

Sometimes a string contains both regular words and numbers, such as a short note or a line from a log. Write a function sum_from_string that takes a string s, splits it by spaces, and adds up all the integers. Anything that is not a number should simply be skipped.

Примеры

Ввод
"hello 3 world 4"
Вывод
7
Ввод
"no numbers here"
Вывод
0
Ввод
"10 20 30"
Вывод
60

Нужно реализовать

def sum_from_string(s: str) -> int:

Теги

stringsmath
PostgreSQLv16

Siia ilmub koodi käivituse tulemus

Visible tests
1
Input
"hello 3 world 4"
Expected7
2
Input
"no numbers here"
Expected0
3
Input
"10 20 30"
Expected60
4
Input
"a 5 b -3 c"
Expected2
5
Input
""
Expected0
6
Input
"abc"
Expected0
Focus radio
Paused · SomaFM · Fluid