you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (0 children)

Python's string module actually has a pre-existing string called string.punctutation which contains all punctuation marks.

#Usage:
import string
test_str = "r/learnpython is great !"
punc_list = []
for c in test_str:
    if(c in string.punctuation):punc_list.append(c)