def if_string_then_convert_to_bytes(val):
    """
    Convert string to bytes array

    Parameters
    ----------
    val : str or bytes

    Returns
    -------
    out : bytes

    """
    if isinstance(val, str):
        return bytearray(val, 'ascii')

    return val