How to check if my list has an item from another list(dictionary)?

前端 未结 2 872
清歌不尽
清歌不尽 2021-01-26 12:38

I\'m a beginner in programming with python, and I\'ve got a question which may have an easy answer.

So I have a dictionary of words which is imported from a .txt file, n

2条回答
  •  隐瞒了意图╮
    2021-01-26 12:56

    Here's a one-liner using for, that generates a set of mispelled words:

    mispelled = { word for word in sentence if word not in dictionary }
    

    I've renamed your variables for clarity

提交回复
热议问题