pay attention to Ryan. Do not use 'str' as an identifier as you will over write the built-in doing so. this seems easiest so far. s = "tyrtrbd =ffgtyuf == =tyryr =u=p ttttff" s = s.replace('=', '=#') print s # -> tyrtrbd =#ffgtyuf =#=# =#tyryr =#u=#p ttttff