I know how to remove all the punctuation in a string.
s = '.$ABC-799-99,#'
table = string.maketrans("","") # to remove punctuation
new_s = s.translate(table, string.punctuation)
You do exactly what you mention in your question, you just str.strip it.
from string import punctuation s = '.$ABC-799-99,#' print(s.strip(punctuation))
str.strip can take multiple characters to remove.
If you just wanted to remove leading punctuation you could str.lstrip:
Or rstrip any trailing punctuation: