Question: Complete the following python code # Verify that the line contains two strings separated by @. def is_email(address): return False # YOU MUST DEFINE THE

Complete the following python code

Complete the following python code # Verify that the line contains two

# Verify that the line contains two strings separated by "@". def is_email(address): return False # YOU MUST DEFINE THE FUNCTION HERE!

# DO NOT EDIT BELOW THIS LINE! # Main program tests several different test cases test_cases = ["fred@mail.com", # True "george", # False, no @ "@randomdomain.org", # False, no user ID "expunge.bob@", # False, no domain "billybob@random@domain"] # False, more than one "@"

print("Test cases:") for case in test_cases: if is_email(case): print("'{}' is valid".format(case)) else: print("'{}' not valid".format(case))

print("Done!") # end of program

Define the function def is_email(address): that accepts a text string containing an email address and returns True if the address is valid, or False otherwise. For this problem, a valid email address must have exactly two non-empty strings with a "@" separator character. Address Return value Note fred@gmail.com True User ID @ domain george False No @ present @randomdomain.org False @present but no characters before expunge. bob@ False @ present but no characters after billybob@random@domain False More than one @ For full marks: Use the given function name and parameter names The function returns its result (not print!) The function uses the given parameters (no "reaching into the main program)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!