🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Exercises.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.

Project 15: Contact Us Form

Python Challenge

Builds on these lessons

Step 1 of 3
Project

A Protocol for Duck Typing

Define class Sendable(Protocol): with a send(self, message) method signature and no implementation. Unlike an ABC (which requires explicit inheritance), any class with a matching send method satisfies Sendable automatically — Python's structural, "if it quacks like a duck" typing, now checkable by a type checker too.

🎯 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 typing import Protocol

class Sendable(Protocol):
    def send(self, message: str) -> None:
        ...

class EmailSender:
    def send(self, message: str) -> None:
        print(f"Emailing: {message}")

def notify(sender: Sendable, message: str) -> None:
    sender.send(message)

notify(EmailSender(), "New contact form submission")