def count_digits (val):
    """ Counts the number of digits in a string.

    Args:
        val (str): The string to count digits in.

    Returns:
        int: The number of digits in the string.
    """
    return sum(1 for c in val if c.isdigit())