Deduplicate a Mailing List

Easy ⏱ 8 min 77% acceptance ★★★★★ 4.5
Write a function unique_emails(emails) that takes a list of email strings and returns the number of distinct addresses. Comparison must be case-insensitive: A@x.com and a@x.com count as one address.

Examples

Example 1
Input
unique_emails(['a@x.com', 'A@x.com', 'b@x.com'])
Output
2
Explanation

The two variants of a@x.com collapse to one after lowercasing.

Constraints

  • Treat addresses case-insensitively.
  • Return an integer count.

Topics

Setsdeduplication

Companies

AmazonSalesforceTCS

Hints

Hint 1

Lowercase each address before adding it to a set.

Hint 2

len() of the set is the answer.

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.