s = "hello % world" s.replace(' %', '') # Need space before % else output is "hello world" # Output: "hello world"