So I recently tried to solve how to get a word from a letter which worked fine by using a function such as:
For word in s.split():
If q in word:
Print word
However, My goal is that what I want to do is that I have a Bad word of list and a Good word to list. My idea was to make a first search for Good words and see which meaning in a letter contains those good word but if that meaning also contains a bad word - then it shouldn't print out the meaning.
etc:
Good word: "Lo", "Yes" Bad word: "Hate", "Not"
Meaning: "Hello guys. My name is Lo and I hate to code :')" <-- "Just a joke!!
So meaning if it search for that meaning it should tell us there is a meaning that contains good and then check if it contains Bad word. If it does then we don't want to print out the meaning but if it doesn't contain any bad word then we should print it out.
How I tried to code was:
good_word = ["Lo", "Yes"]
bad_word = ["Hate", "Not"]
for text in good_word:
if text in text_roman['meaning']:
print("Yay found word " + text_roman['meaning'])
for bad_text in bad_word:
if bad_text not in text_roman['meaning']:
print("Yay no bad words!")
When I tried this, the output gave all the words that contains the bad words aswell unfortunately
Aucun commentaire:
Enregistrer un commentaire