Question: class EmailNotValidError ( ) : Raised when the target email is not valid def is _ email _ valid
class EmailNotValidError:
Raised when the target email is not valid
def isemailvalidmailinglist:
for key, email in mailinglist.items: # Loop through the mailing list:
if @ not in email: # Check if the email contains an @:
raise # Raise an EmailNotValidError exception if the @ is not present
def isemailvalidextendedmailinglist:
finaluserslist # Array to hold user ids
# Inserted a try.., except.. block to cast the exception
try:
# Loop through the mailing list
for key, email in mailinglist.items: # Your mailing list:
if @ in email: # Check if the @ is present in the email:
# Append the id of users with valid emails
else:
raise # Raises an EmailNotValidError otherwise
except # Your userdefined exception:
return # Return a userfriendly message to cast the exception
def isemailvalidextendedfinallymailinglist:
finaluserslist.appendkey # Array to hold user ids
# Inserted a try.., except.. block to cast the exception
try:
# Loop through the mailing list
for key, email in # Your mailing list:
if @ in # Check if the @ is present in the email:
# Append the id of users with valid emails
else:
raise # Raises an EmailNotValidError otherwise
except # Your userdefined exception:
# Print a userfriendly message to cast the exception
finally:
return # Return the id of the users with valid email
How do you fix this code?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
