<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def hexameter(self, line: str) -> str: """ Format a string of hexameter metrical stress patterns into foot divisions :param line: the scansion pattern :return: the scansion string formatted with foot breaks -UU|-UU|-UU|--|-UU|-- """

        mylist = list(line)
        items = len(mylist)
        idx_start = items - 2
        idx_end = items
        while idx_start > 0:
            potential_foot = "".join(mylist[idx_start: idx_end])
            if potential_foot == self.constants.HEXAMETER_ENDING or \
                            potential_foot == self.constants.SPONDEE:
                mylist.insert(idx_start, self.constants.FOOT_SEPARATOR)
                idx_start -= 1
                idx_end -= 2
            if potential_foot == self.constants.DACTYL:
                mylist.insert(idx_start, "|")
                idx_start -= 1
                idx_end -= 3
            idx_start -= 1
        return "".join(mylist)