<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def insert_ansi(p_string):
 """ Returns a string with color information at the right positions. """

    result = p_string.data

    for pos, color in sorted(p_string.colors.items(), reverse=True):
        color = lookup_color(color)

        result = result[:pos] + color.as_ansi() + result[pos:]

    return result