Set Comprehensions
PY · Tuples & Setssyntax
{expression for item in iterable if condition}example
emails = ["[email protected]", "[email protected]", "[email protected]", "[email protected]"]
unique_lower = {e.lower() for e in emails}
print(unique_lower)output
{'[email protected]', '[email protected]', '[email protected]'}Note Set comprehensions automatically deduplicate results. Useful for extracting unique transformed values from a collection.