Syntax error with escape character \'N\' while creating a procedure using python

I am trying to create a stored procedure in database through python function.

procedure_str = """CREATE or replace PROCEDURE sp_target(  in_cols varchar , in_where_key varchar  , 
    out_view_name out varchar(256) ) AS $$  
    EXECUTE 'create or replace view '||  name || ' as ' ||
    'select ' || in_cols || ' from target'||
    'where status ='||' \'N\' '|| and rank = 1;
    $$ LANGUAGE plpgsql ;"""


When I execute the statement, sp_target procedure should be created. But it is showing me a syntax error near ' \'N\' '. I need to have N as 'N' after creating the procedure. Can anyone help.