I am requesting an API which sometimes gives a string that contain "*" characters.
I have to post the output on discord, where ** makes the text bold.
I want to see if a string contains any * and if so put a markdown \ escape character in front of the *.
How can I accomplish this?
As @Random Davis rightly pointed out in the comments, you can use str.replace("*","\*")and it will replace all the * occurrence.
If character in string put escape character "\" in front of the found character