Add the Digits

Text often mixes letters, numbers, spaces, and punctuation, but sometimes you only need the numeric parts. The function sum_digits_in_string receives a string s and adds together every digit character it finds. Ignore letters, spaces, and all other characters.

Примеры

Ввод
"a1b2c3"
Вывод
6
Ввод
"abc"
Вывод
0
Ввод
"123"
Вывод
6

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

def sum_digits_in_string(s: str) -> int:

Теги

stringsmath
PostgreSQLv16

Hier erscheint das Ergebnis der Codeausführung

Visible tests
1
Input
"a1b2c3"
Expected6
2
Input
"abc"
Expected0
3
Input
"123"
Expected6
4
Input
""
Expected0
5
Input
"x9y9"
Expected18
6
Input
"Hello, World!"
Expected0
Focus radio
Paused · SomaFM · Fluid