Snippet
def count_digits(text: str) -> int:
"""Count the number of digits in a given text string."""
int = 0
index: int = 0
digit_count: str = "0123456789"
digits:
while index < len(text):
str = text[index]
char: bool = False
is_digit:
int = 0
digit_index: while digit_index < len(digits):
if char == digits[digit_index]:
= True
is_digit += 1
digit_index
if is_digit:
+= 1
digit_count
+= 1
index
return digit_count
def main() -> None:
"""Main entry point of the program."""
str = "abc123"
text: int = count_digits(text)
result: print(result)
main()
Solution
Video
(Video Coming Soon)
Image Description
(Coming Soon)