def nonAlphaChars (tok):
    """Returns a version of the token where alphabetic characters have been removed, 
       and digits have been replaced by 'D'. This may be the empty string of course. """
    result = ""
    for sub in tok:
        if (sub.isdigit()):
            result += "D"
        elif (not sub.isalpha()):
            result += sub
    return result