How to recode line so an exact sentence must be in the list for it to match
<pre><code>x = ["Cookie flavored water is yummy 6", "Coding complicated 16", "Help 7"]

for i in x:
    if "flavored" in x:
        print ("Yes")
    else:
        print ("No")
</code></pre>

<p>I want the exact string "Cookie flavored water is yummy" to be in the list for it to be acceptable but I don't want the 6 part included. I'm completely befuddled on how to accomplish this. Also the objective might change from the first element to a different element.</p>

<p>Well if the string is always the one you specified you could do this:</p>

<pre><code>yourString = "Cookie flavored water is yummy"
for item in x:
    if yourString in item:
        print 'Yes'
    else:
        print 'No'
</code></pre>

<p>This check each list item for the specified string. In your example "Cookie flavored water is yummy 6" contains the substring "Cookie flavored water is yummy". So the script will print 'Yes'</p>

python list