<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def fmt_val(val, shorten=True):
 """Format a value for inclusion in an informative text string. """

    val = repr(val)
    max = 50
    if shorten:
        if len(val) > max:
            close = val[-1]
            val = val[0:max-4] + "..."
            if close in (">", "'", '"', ']', '}', ')'):
                val = val + close
    return val