0

I know there have been multiple versions of questions like this but i can't seem to be able to put it together.

What I want: I have a string like "My name is Peter". Then I have a string such as "NFTY". What I want to do in python is go through and swap every occurrence of N with F and every occurrence of T with Y in the original string. (I.e. My name is Peter will now become "My fame is Peyer"

I'd want to do it such that the case of "NFTY" doesn't matter as long as the function sees that N has occurred in the original string whether its upper or lower case.

Any help would be appreciated!

user341191
  • 13
  • 3
  • I have linked two questions. The first https://stackoverflow.com/questions/9475241/split-string-every-nth-character shows you how to get `["NF", "TY"]` for example. The second, shows you how to use that to replace the string i.e. `for r in ["NF", "TY"]: s = s.replace(*r)`. See if you can work that out into a solution and if not please [edit] with your attempt and ask about that – Tomerikoo Mar 29 '23 at 07:27

0 Answers0