function to remove and punctuation

Steven D'Aprano steve at pearwood.info
Sun Apr 10 08:08:59 EDT 2016


On Sun, 10 Apr 2016 09:37 pm, geshdus at gmail.com wrote:

> how to write a function taking a string parameter, which returns it after
> you delete the spaces, punctuation marks, accented characters in python ?

In your text editor, open a new file.

Now bash your fingers onto the keyboard so that letters appear in the file. 

When you have the function, click Save.

(Sorry, I couldn't resist.)


Here is one to get you started:


def remove_punctuation(the_string):
    the_string = the_string.replace(".", "")
    return the_string



-- 
Steven




More information about the Python-list mailing list