django - Try / except syntax in Python with two of the same exceptions -


i checking emails against 2 lists -- list of domains , list of individual emails. how construct following try statement --

try: 'email in email_list'  except doesnotexist: 'domain in domain list' # if email not found  except doesnotexist: 'print error message'   # if both email , domain not found 

what syntax need use construct statement?

it sounds you're looking like:

if email in email_list:     # email elif domain in domain_list:     # domain else:     print "neither email nor domain found" 

there no need exceptions in case.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -