Embrace comprehensions

In addition to the well-known list comprehension, Python has many other comprehension expressions…

Set comprehension

Set comprehension is enclosed in curly braces {} and acts almost like list comprehension, except that the result is a set with the duplicates removed. We could accomplish the same effect by applying set() to list comprehension, but set comprehension is considerably faster:

Get hands-on with 1200+ tech skills courses.