import re
def replace_punctuation(string, ch):
return re.sub(r"[^\w\s]", " ", string)
# \w = letters, digits, underscore
# \s = whitespace
# [^...] = “anything not in this set” → punctuation
string = "In my opinion, we ;need * to keep? write code and use AI. "
string = replace_punctuation(string, ' ')
print(string)
'''
run:
In my opinion we need to keep write code and use AI
'''