Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Clean and simple solution in Clear category for Count Digits by Celshade
def count_digits(text: str) -> int:
"""Return the number of individual digits found within the string.
e.g. '1945' -> 4
Args:
text: The given string to parse.
"""
digits = 0
for item in text.split(' '):
digits += len([char for char in item if char.isdigit()])
return digits
June 7, 2020