I want to remove certain characters from a string in Python, how can I do this? Here is an example of the string:
my_string = "Hello, World! This is a test string."
I want to remove the commas and exclamation marks from the string so that it becomes:
"Hello World This is a test string"
I tried using the replace()
method, but it only works for one character at a time. Can anyone suggest a better way to achieve this?
Here is the code I tried:
I would appreciate any suggestions or alternative methods for achieving this. Thank you!