replace a part of a string in python without replace()

  python, replace, string

I was wondering how you would be able to take a string, check if a certain character(s) is in it and replace that with another string WITHOUT using .replace()
so for example,

if i had an input "cat in a hat cat", and wanted to change all the "cat"’s to "bat", it would become "bat in a hat bat".

Source: Python Questions

LEAVE A COMMENT