0
Check the email is correct or not that must include '@' and '.' And the @ must appear before the '.'
2 Answers
+ 2
As the Igor mentioned, it's possible for the string or email to have a dot before the "@", so:
def isEmail(string):
return y in string for y in ["@", "."] and \
string.rindex(".") > string.rindex("@")
That should work. What it's saying is that if "." and "@" are in the string (that way if the attempt to find either with "rindex" fails it doesn't throw an error) and if the last occurance of the "." is later than the last occurrence of the "@", then it will return true, else false.
Although you might be better off using Regular Expression to parse the emails.
+ 1
email addresses may have periods before @ signs.