Learning Scientific Programming with Python (2nd edition)
P2.6.2: Censoring a text
Question P2.6.2
Write a program to read in a text file and censor any words in it which are on a list of banned words by replacing their letters with the same number of asterisks. Your program should store the banned words in lower case but censor examples of these words in any case. Assume there is no punctuation.
As a bonus exercise, handle text which contains punctuation. For example, given the list of banned words: ['C', 'Perl', 'Fortran']
the sentence:
'Some alternative programming languages to Python are C, C++, Perl, Fortran and Java.'
becomes:
'Some alternative programming languages to Python are *, C++, ****, ******* and Java.'