Censor - about replace method

hey, why does this happen?
and, why doesn’t “for” work instead of "if’ for this method?

Why wouldn’t this happen? you instruct python to replace all instances found by something else.

you don’t need for or if at all when using replace. Replace will replace everything it can find (so if nothing is found, nothing is replaced)

thanks. trying to understand the logic- the code above works with “if” but not with “for”.

Why would you want to use for? or if for that matter? .replace() does all the heavy lifting

can I see the code of which you claim for doesn’t work?

1 Like