Loading...

The Event Broadcaster

A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.

Domain
Python
Difficulty
medium
Seniority
mid, senior

Problem

A notification system needs to allow components to subscribe to named events and receive callbacks when those events fire. Implement an EventEmitter class with on (subscribe), emit (fire), and off (unsubscribe) methods. Multiple listeners can be registered for the same event.

Practice This Problem

Solve this Python problem with real code execution. DataDriven runs your Python code in a sandboxed Docker environment and grades it instantly.