-2

Im new to coding and am looking for some help.

I need to remove words of a small list from a large list.

clean_book = [word for word in bwords_split if word in words_list]

I used the line above where bwords_split is the larger list and words_list is the smaller list and clean_book is the result. I think I'm thinking to arthemetically. Could someone help me?

Chris
  • 26,361
  • 5
  • 21
  • 42
  • If you replace `in` with `not in`, that would work (although some might complain it is not efficient). If that's not what you want, what issues are you facing currently? – j1-lee Feb 07 '22 at 02:31
  • If you need to remove the words in `words_list` from `bwords_split`, then you're doing it backwards. You'll end up with nothing _but_ those words. Just negate your condition in your list comprehension. – Chris Feb 07 '22 at 02:32

1 Answers1

0

Your solution looks fine. Just change the second "in" to "not in"

William
  • 324
  • 1
  • 8