The following function returns a new string without the punctuations that were in the string that was passed in. Although the code works, who can it be done using the .replace() method. This part of an assignment where the hint is to use the .replace() method but strings are immutable so how do I use the .replace() method to remove punctuation? Thank you.
punctuation_chars = ["'", '"', ",", ".", "!", ":", ";", '#', '@']
def strip_punct(s):
new_s = ''
for c in s:
if c in punctuation_chars:
continue
new_s += c
return new_s
a_string = 'He;-;l####lo.'
print(strip_punct(a_string)) # prints He-llo