def set_char(s, n, c):
    """Set the nth char of s to be c, extending s if needed."""
    s = s.ljust(n)
    return s[:n] + c + s[n+1:]
Set the nth char of s to be c, extending s if needed.
lab/parser.py