title: python check for a valid email
body: <p>Python Central published this <a href="https://www.pythoncentral.io/how-to-validate-an-email-address-using-python/" rel="nofollow noreferrer">simple script</a> on the 29th December 2016 to check for a properly formatted email. </p>
  
  <pre><code>import re
  
  def isValidEmail(email):
      if len(email) &gt; 7:
          if re.match("^.+@([?)[a-zA-Z0-9-.]+.([a-zA-Z]{2,3}|[0-9]{1,3})(]?)$", email) != None:
              return True
          return False
  
  if isValidEmail("my.email@gmail.com") == True:
      print("This is a valid email address")
  else:
      print("This is not a valid email address")
  </code></pre>
  
  <p>While trying it, python 3 returned the following error messages:</p>
  
  <pre><code>Traceback (most recent call last):
    File "~/isValidEmail.py", line 11, in &lt;module&gt;
      if isValidEmail("my.email@gmail.com") == True:
    File "~/isValidEmail.py", line 7, in isValidEmail
      if re.match("^.+@([?)[a-zA-Z0-9-.]+.([a-zA-Z]{2,3}|[0-9]{1,3})(]?)$", email) != None:
    File "/usr/lib/python3.5/re.py", line 163, in match
      return _compile(pattern, flags).match(string)
    File "/usr/lib/python3.5/re.py", line 293, in _compile
      p = sre_compile.compile(pattern, flags)
    File "/usr/lib/python3.5/sre_compile.py", line 536, in compile
      p = sre_parse.parse(p, flags)
    File "/usr/lib/python3.5/sre_parse.py", line 829, in parse
      p = _parse_sub(source, pattern, 0)
    File "/usr/lib/python3.5/sre_parse.py", line 437, in _parse_sub
      itemsappend(_parse(source, state))
    File "/usr/lib/python3.5/sre_parse.py", line 781, in _parse
      source.tell() - start)
  sre_constants.error: missing ), unterminated subpattern at position 4
  </code></pre>
  
  <p>How may I fix this error?</p>