1 2 3 4 5 6 7 8 9 10 11 12 | import re def main(): fh = open ('rotf.txt') v = input('What word would you like to change? ') b = input('What word would you like to swap it with? ') for line in fh: match = re.search(v, line) if match: print(line.replace(match.group(), b), end='') main() |
In the list there are songs consisting of the 'f' word (if you know what I mean) so i wanted to change the 'f' word, to 'caress', and this is what i got:
Caress Her Gently
Hard Caressing
I Wanna Caress You
They Caressed Our Asses
(I found this very amusing)