1using re adds white-space before and after the desired characters:
23import re
45pat = re.compile(r"([.()!])")
6print (pat.sub(" \\1 ", string))
7# hello . . . ( world ) !
you will get a confirmation link on this - you will have to click that for successful submission of your answer. we require this to keep the website free of spam, bots and unhelpful content
please ensure to add code which is syntactically corrent and executes properly
you will get a confirmation link on this - you will have to click that for successful submission of your question. we require this to keep the website free of spam, bots and unhelpful content