Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
2 Solutions in 1 solution in Clear category for Unique Email Addresses by Alex_4444D
import re
def unique_emails(emails: list[str]) -> int:
list_ = []
for i in emails:
if re.fullmatch(r'\w+@\w+.\w+', i):
list_.append(i)
return len(list_)
#or
import re
def unique_emails(emails: list[int]) -> int:
return len(set([re.sub('\.(.*)@', '\\1@', re.sub('\+.*@', '@', m.lower())) for m in 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!")
Dec. 1, 2021
Comments: