def trim_noncoding(transcript, max_length=0):
    """
    Function to trim the terminal exons for non-coding transcripts,
     i.e. the simplest case.

    :param transcript: the transcript to be trimmed.
    :type transcript: Transcript

    :param max_length: maximum length of terminal exons.
    :type max_length: int

    :return: transcript
    :rtype: Transcript

    """
    transcript.unfinalize()
    exons = sorted(transcript.exons)
    first, last = exons[0], exons[-1]
    if first[1] - first[0] + 1 > max_length:
        newfirst = tuple([first[1] - max_length, first[1]])
        transcript.start = newfirst[0]
        transcript.remove_exon(first)
        transcript.add_exon(newfirst)
    if last[1] - last[0] + 1 > max_length:
        newlast = tuple([last[0], last[0] + max_length])
        transcript.end = last[0] + max_length
        transcript.remove_exon(last)
        transcript.add_exon(newlast)
    return transcript
