Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second solution in Clear category for Unique Email Addresses by PythonLearner
def normalize(email: str) -> str:
name, domain = email.lower().split("@")
if name.count("+") > 0:
name = name.split("+")[0]
normalized_name = name.replace(".", "")
return f"{normalized_name}@{domain}"
def unique_emails(emails: list[str]) -> int:
return len(set(map(normalize, emails)))
print("Example:")
print(unique_emails(["alex@checkio.org", "mike@google.com", "lili@apple.com"]))
assert unique_emails(["alex@checkio.org", "mike@google.com", "lili@apple.com"]) == 3
assert (
unique_emails(
["mi.ke@google.com", "alex@checkio.org", "mike@google.com", "lili@apple.com"]
)
== 3
)
assert (
unique_emails(
[
"alex+home@checkio.org",
"lili+work@apple.com",
"alex@checkio.org",
"lili@apple.com",
]
)
== 2
)
assert (
unique_emails(
[
"l.ili+work@apple.com",
"a.lex@checkio.org",
"alex+home@checkio.org",
"lili+work@apple.com",
"alex@checkio.org",
"lili@apple.com",
]
)
== 2
)
assert unique_emails(["Alex@checkIO.org", "alex@checkio.org", "alex@check.io.org"]) == 2
assert unique_emails([]) == 0
print("The first mission is done! Click 'Check' to earn cool rewards!")
Nov. 18, 2021
Comments: