Program - python code to remove punctuation from the string


Topic: Program - python code to remove punctuation from the string

Solution

def r_punc():
    test_str = "end, is best : for ! Nlp ;"
    print("The original string is : " + test_str)
    punc = '''!()-[]{};:'"\, <>./?@#$%^&*_~'''
    for ele in test_str:
        if ele in punc:
            test_str = test_str.replace(ele, "")
    print("The string after punctuation filter : " + test_str)
htness_4



List all Python Programs