I have a server_list and I am parsing email addresses from a file. I want to collect all addresses that are not from certain servers e.g. gmail.com.
Currently I have this inside the file reading loop:
server_list = ["gmail.com", "yahoo.com"] #etc
for servers in server_list:
if servers in emailaddress: #get emailaddress from inside of a open(file) line loop
badmail.extend(emailaddress)
This allows me to collect the bad emails in a list badmail. Is there any way to create a list of good emails i.e. if emailaddress is not contained in any items in server_list in the same loop or do I have to create a list of all emails and remove the bad emails?
elseemailaddress? A list?if any(servers in emailaddress for servers in server_list):. Also, you probably want toappend, notextend, the list, assuming it's a string.