Hello I have a string which contains a mail address. For example ( [email protected] ) And I have a list which contains only domains ('bar.com','stackoverflow.com') etc.
I want to search the list if it contains my string's domain. Right now I am using a code like this
if tokens[1].partition("@")[2] in domainlist:
tokens[1] contains the mail address and domainlist contains the domains.
But as you can see the result of tokens[1].partition("@")[2] will return foo.bar.com but my list has the domain bar.com.
How can I make this if statement return true? And it should be very fast because hundreds of mail addresses will come in every second
.partition("@")[2]will fail for certain types of email addresses. See stackoverflow.com/questions/5908190/… for how to do so.