0

Another question with files

I have dictionary in txt file with more than 350000 words, one word each line. I only need some of these words. Lets say ie. containing letters V, X, Q alone and with all of them. Should i use regex? How beat this problem?

18th Feb 2017, 10:07 PM
guest013
guest013 - avatar
3 Answers
+ 2
Almost ;) You must correct the writing of your 'if' statement... instead your: if 'v' or 'x' or 'q' in word: ... correct syntax is: if 'v' in word or 'x' in word or 'q' in word: newDB.append(word) ( Obviously, you have to pass something to the method 'append()' :P )
19th Feb 2017, 7:02 AM
visph
visph - avatar
0
Main idea was to have only correct words in this database and each time randomly get 50 words into list. But still dont know how get rid of not correct words. I think it should be something like this: newDB = [ ] if 'v' or 'x' or 'q' in word: newDB.append() Is it good idea?
18th Feb 2017, 10:40 PM
guest013
guest013 - avatar