A simple depunctuator with and without regexes
✓ Published0🌍 Public
Aamundo
Last edited Mar 18, 2014
Created on Mar 18, 2014
This example demonstrates a simple text-cleaning function that removes unwanted characters from strings, using two sample sentences to show the before-and-after effect. The code defines a `depunctuate` function in Python, which iterates through each character of the input and builds a new string by excluding any letters found in a provided `badletters` set. It uses basic string concatenation and a `for` loop, with no external libraries. Two print statements call the function: the first strips punctuation like periods and exclamation marks, while the second removes digits and commas from a numeric phrase.
AI-generated description