Problem 194962 · easy · Phase 01 Prerequisites & Setup

Sum the Digits Hidden in Text

strings · iteration · isdigit · int

A receipt has been mangled into a single string with letters and digits mixed together. Given s, return the sum of every digit character that appears in it (each digit counted on its own, so "42" contributes 4 + 2).

Examples

Input:  s = "a1b2c3"
Output: 6

Input:  s = "Room 305, floor 12"
Output: 11

Constraints

  • 0 <= len(s) <= 5000
  • s may contain letters, digits, spaces and punctuation

Goals

  • Recognise digit characters with `isdigit`
  • Convert a character to an integer
  • Accumulate a total
Starting Python…