def fmt_quil_str(raw_str):
    """Format a raw Quil program string
    Args:
        raw_str (str): Quil program typed in by user.

    Returns:
        str: The Quil program with leading/trailing whitespace trimmed.
    """
    raw_quil_str = str(raw_str)
    raw_quil_str_arr = raw_quil_str.split('\n')

    trimmed_quil_str_arr = [qs.strip() for qs in raw_quil_str_arr]
    trimmed_quil_str = '\n'.join([x for x in trimmed_quil_str_arr])

    return trimmed_quil_str