0

Check the email is correct or not that must include '@' and '.' And the @ must appear before the '.'

17th Dec 2016, 3:51 AM
amrr
2 Respuestas
+ 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.
17th Dec 2016, 4:54 AM
Riley Johnson
Riley Johnson - avatar
+ 1
email addresses may have periods before @ signs.
17th Dec 2016, 3:56 AM
Igor B
Igor B - avatar