<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write_messages(ax, messages):
 """ Write text on canvas, usually on the top right corner. """

    tc = "gray"
    axt = ax.transAxes
    yy = .95
    for msg in messages:
        ax.text(.95, yy, msg, color=tc, transform=axt, ha="right")
        yy -= .05