Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing

Extract all email addresses from a nested payload

Python data engineering interview problem. Difficulty: intermediate. Pattern: Recursion. About 15 minutes. Part of the Pro drill bank.

A webhook payload nests email addresses several layers down. A support tool should collect every address without the caller knowing the shape.

Extract all email addresses from a nested payload (dict/list mix).

Requirements

  • Walk dicts and lists recursively.
  • Collect strings that look like emails.

Constraints

  • payload: nested JSON-like structure.
  • Duplicates: follow the tests (keep vs unique).

Examples

Input: collect_emails({'a': 'x@y.com', 'b': ['no', {'c': 'a@b.co'}]}) Output: ['a@b.co', 'x@y.com'] This input follows the stated rules and produces this output.

Topics: lakebench, python, nested-structures.

More Python interview questions · All interview problems · Learn data engineering

intermediate

Extract all email addresses from a nested payload

Interview-style drill: Given an arbitrarily nested dict/list structure, collect every value that looks like an email address.

Extract all email addresses from a nested payload (dict/list mix).