Python string clean-up | SoloLearn: Learn to code for FREE!


Python string clean-up

How would you start going about when you have a bunch of dirty OCR text files from and you want to throw out every word that is not included in a list of words in a dictionary? I want to do that in Python... Any help appreciated! ;)

5/16/2019 8:41:46 PM


4 Answers

New Answer


words = [word for word in list if word in dictionary] Steven I think those are both syntactically wrong 🤔


Steven thank you for taking the time and answering in an abstract yet detailed way. I will see what I can do!


Hehe thanks Anna


Following up on my own question: I figured out a way that works for me without much hassle, comparing the text as a set using difference ():