Modify the following Python code to detect and remove punctuation from a given string.
my_string = 'Hello, world!'
my_string = 'Hello, world!'
punctuation = '!,.'
for char in my_string: 
 if char in punctuation: 
 my_string = my_string.replace(char, "")

print(my_string)
# Output: Hello world