def upperLevelCredits (theDictionary):
    """Counts the number of upper-level undergraduate credits.

    :param dict[str, int] theDictionary: The student's class information
        with the class as the key and the number or credits as the value
    :return: The number of credits
    :rtype: int
    """
    numCredits = 0

    for i in theDictionary:
        deptAndNum = i.split ()
        if int (deptAndNum[1][:3]) in range(300, 500):
            numCredits += theDictionary[i]

    return numCredits