Project 14: Newsletter Form
Python Challenge
Builds on these lessons
Step 1 of 3
Project
An Abstract Base Class for Validators
Define class Validator(ABC): with an @abstractmethod validate(self, value) method that has no body — a contract, not an implementation. Python refuses to instantiate Validator directly, or any subclass that doesn't implement validate, which catches an incomplete implementation immediately rather than at some confusing runtime moment later.
🎯 Your Task
Please add the exact code shown in the light gray box below to your editor.Do not delete your previous code, just insert these new lines in the correct place!
from abc import ABC, abstractmethod
class Validator(ABC):
@abstractmethod
def validate(self, value):
...
class EmailValidator(Validator):
def validate(self, value):
return "@" in value
print(EmailValidator().validate("reader@example.com"))