Python simple email validity check
<p>In Python, if i wanted to write something that returns a boolean True as long as the @ symbol appears after the . symbol, how would I write this? </p>

<p>I have tried writing something like:</p>

<pre><code>if myString[x] == "@" &gt; myString[x] == ".":
     return True
</code></pre>

<p>but, I assume that this won't work because they're both essentially the same index. Looking for some explanation as well, just learning a lot of basics still. 
Thanks!</p>

<p>You could use a simple regular expression:</p>

<pre><code>import re

rx = re.compile(r'\S+@\S+')

string = """This text contains an email@address.com somewhere"""

if rx.search(string):
    print("Somewhere in there is an email address")
</code></pre>

<p>See <a href="http://ideone.com/7FpfgH" rel="nofollow"><strong>a demo on ideone.com</strong></a>.</p>

python