title: How do I catch "split" exceptions in python?
body: <p>I am trying to parse a list of email addresses to remove the username and '@' symbol only leaving the domain name.</p>
  
  <p>Example: blahblah@gmail.com
  Desired output: gmail.com</p>
  
  <p>I have accomplished this with the following code:</p>
  
  <pre><code>for row in cr: 
      emailaddy = row[0]
      (emailuser, domain) = row[0].split('@')
      print domain
  </code></pre>
  
  <p>but my issue is when I encounter a improperly formatted email address.  For example if the row contains "aaaaaaaaa" (instead of a valid email address) the program crashes with the error </p>
  
  <pre><code>(emailuser, domain) = row[0].split('@')
  ValueError: need more than 1 value to unpack. 
  </code></pre>
  
  <p>(as you would expect) Rather than check all the email addresses for their validity, I would rather just not update grab the domain and move on to the next record. How can I properly handle this error and just move on?</p>
  
  <p>So for the list of:</p>
  
  <pre><code>blahblah@gmail.com
  mmymymy@hotmail.com
  youououou
  nonononon@yahoo.com
  </code></pre>
  
  <p>I would like the output to be:</p>
  
  <pre><code>gmail.com
  hotmail.com
  
  yahoo.com
  </code></pre>
  
  <p>Thanks!</p>