Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Now that you've posted your code… I don't know what problem you were asking about, but there's at least one thing obviously wrong with it.</p> <p><code>sentences</code> is a list of sentences.</p> <p>So, <code>for partial in sentences</code> means each <code>partial</code> will be a sentence, like <code>"I am impeccable"</code>.</p> <p><code>dictionary</code> is a list of words. So, <code>for value in dictionary</code> means each <code>value</code> will be a word, like <code>"impeccable"</code>.</p> <p>Now, you're checking <code>partial in value</code> for each value for each partial. That will never be true. <code>"I am impeccable"</code> is not in <code>"impeccable"</code>.</p> <p>If you turn that around, and check whether <code>value in partial</code>, it will give you something that's at least true sometimes, and that may even be what you actually want, but I'm not sure.</p> <p>As a side note, if you used better names for your variables, this would be a lot more obvious. <code>partial</code> and <code>value</code> don't tell you what those things actually are; if you'd called them <code>sentence</code> and <code>word</code> it would be pretty clear that <code>sentence in word</code> is never going to be true, and that <code>word in sentence</code> is probably what you wanted.</p> <p>Also, it really helps to look at intermediate values to debug things like this. When you use an explicit <code>for</code> statement, you can <code>print(partial)</code> to see each thing that <code>partial</code> holds, or you can put a breakpoint in your debugger, or you can step through in a visualizer like <a href="http://pythontutor.com/visualize.html#mode=display" rel="nofollow">this one</a>. If you have to break the <code>any(genexpr)</code> up into an explicit loop to do, then do so. (If you don't know how, then you probably don't understand what generator expressions or the <code>any</code> function do, and have just copied and pasted random code you didn't understand and tried changing random things until it worked… in which case you should stop doing that and learn what they actually mean.)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload