Python check if string got a certain word (or combination of characters)
<p>Ok so I have this string (for example):</p>

<pre><code>var = "I eat breakfast."
</code></pre>

<p>What i would like to do is to check if that string has the letters "ea", and I wanted to be able to put those values into a list.</p>

<p>I tried using var[x] but I can only have one character at the same time and not a word right?</p>

<p>You can use <code>in</code> to check if a string contains a substring. It also sounds like you want to add <code>var</code> to a list if it contains a substring. Observe the following interactive session:</p>

<pre><code>In [1]: var = "I eat breakfast."

In [2]: lst = []

In [3]: if "ea" in var:
   ...:     lst.append(var)
   ...:     

In [4]: lst
Out[4]: ['I eat breakfast.']
</code></pre>

python python-3.x