I am trying to split a string but it should be replaced to another string and return as a list. Its hard to explain so here is an example:
I have string in variable a
:
a = "Hello World!"
I want a list such that:
a.split("Hello").replace("Hey") == ["Hey"," World!"]
It means I want to split a string and write another string to that splited element in the list. SO if a
is
a = "Hello World! Hello Everybody"
and I use something like a.split("Hello").replace("Hey")
, then the output should be:
a = ["Hey"," World! ","Hey"," Everybody"]
How can I achieve this?