Homework

Email validator

Create a function that validates an email address.

def isValidEmail(email):
    return False

An email is considered valid if:

  • It has exactly one @ symbol

  • It has at least one .

  • There is at least one . following the @ symbol

  • There is at least one character before the @

  • There is at least one character between the @ and .

  • There is at least one character after the final .

Hints:

  • Splitting the string might help (more than once)

  • Splitting the string might not be the only thing to do

  • Break down the problem in order of simplest thing to check.

Test your code to see if it gets the correct output

isValidEmail("alex@general.assembly") # true
isValidEmail("alex.y@general.a") # true
isValidEmail("@alex.general") # false
isValidEmail("alex.general@") # false
isValidEmail("alex@general") # false
isValidEmail("a@g.a") # true
isValidEmail("alex@g.") # false
isValidEmail("alex@.ga") # false
isValidEmail("alex.general@assembly") # false
isValidEmail("alex") # false
isValidEmail("@.") # false

Last updated