def count_words (val):
    """ Counts the number of words in a string.

    A word is defined as a sequence of one or more letters separated by one or more non-letter characters.

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

    Returns:
        int: The number of words in the string.
    """
    current = 0
    count = 0
    in_word = False
    while current < len(val):
        if not in_word and val[current].isalpha():
            in_word = True
            count += 1
        elif in_word and not val[current].isalpha():
            in_word = False
        current += 1
    return count