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
Accedi per vedere la cronologia degli invii
AccediAccedi per usare l'AI Mentor
AccediVisible tests
1
Input
"a1b2c3"Expected
62
Input
"abc"Expected
03
Input
"123"Expected
64
Input
""Expected
05
Input
"x9y9"Expected
186
Input
"Hello, World!"Expected
0Focus radio
Paused · SomaFM · Fluid