<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_syllables_with_trailing_spaces(line: str, syllables: List[str]) -> List[str]: """ Given a line of syllables and spaces, and a list of syllables, produce a list of the syllables with trailing spaces attached as approriate. :param line: :param syllables: :return: [' ar', 'ma ', 'vi', 'rum', 'que ', 'ca', 'no '] """

    syllabs_spaces = []
    idx = 0
    linelen = len(line)
    for position, syl in enumerate(syllables):
        start = line.index(syl, idx)
        idx = start + len(syl)
        if position == 0 and start > 0:  # line starts with punctuation, substituted w/ spaces
            syl = (start * " ") + syl
        if idx + 1 > len(line):
            syllabs_spaces.append(syl)
            return syllabs_spaces
        nextchar = line[idx]
        if nextchar != " ":
            syllabs_spaces.append(syl)
            continue
        else:
            tmpidx = idx
            while tmpidx < linelen and nextchar == " ":
                syl += " "
                tmpidx += 1
                if tmpidx == linelen:
                    syllabs_spaces.append(syl)
                    return syllabs_spaces
                nextchar = line[tmpidx]
            idx = tmpidx - 1
            syllabs_spaces.append(syl)
    return syllabs_spaces