Sum ticket digits

Write codeEasy10 min

Your task

An audit script fingerprints ticket IDs by summing the digit characters they contain. Given a string that may mix letters, digits, and punctuation, return the sum of all digit characters as a number. Return 0 if there are no digits. For example, 'ord-42x9' contains 4, 2, and 9, so the answer is 15.

Examples

digit_sum(s: str) -> int
Example 1
Inputdigit_sum("ord-42x9")
Output15