def count_ncmonomials(monomials, degree):
ncmoncount = <NUM_LIT:0><EOL>for monomial in monomials:<EOL><INDENT>if ncdegree(monomial) <= degree:<EOL><INDENT>ncmoncount += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>break<EOL><DEDENT><DEDENT>return ncmoncount<EOL>
Given a list of monomials, it counts those that have a certain degree,
    or less. The function is useful when certain monomials were eliminated
    from the basis.

    :param variables: The noncommutative variables making up the monomials
    :param monomials: List of monomials (the monomial basis).
    :param degree:  Maximum degree to count.

    :returns: The count of appropriate monomials.