If you have a Python list, and want to remove all punctuation, then you can do the following:

First get all punctuation by using string.punctuation

1
2
import string
print(string.punctuation)

Output:

1
!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~

Option 1 – Using for

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
import string
words = ["hell'o", "Hi,", "bye bye", "good bye", ""]
new_words = []
for word in words:
    if word == "":
        words.remove(word)
    else:
        for letter in word:
            if letter in string.punctuation:
                word = word.replace(letter,"")   
        new_words.append(word)
print(new_words)

Option 2 – Using List Comprehensions

1
2
3
4
import string
words = ["hell'o", "Hi,", "bye bye", "good bye", ""]
words = [''.join(letter for letter in word if letter not in string.punctuation) for word in words if word]
print(words)

Option 3 – Using str.translate()

1
2
3
4
import string
words = ["hell'o", "Hi,", "bye bye", "good bye", ""]
words = [word.translate(string.punctuation) for word in words if word]
print(words)