Home / Python Tips Generated By ChatGPT / Comprehensions for Sets and Dictionaries in Python Similar to list comprehensions, but for sets and dictionaries. Source Code # Set comprehension squared_set = {x**2 for x in range(10)} # Dictionary comprehension squared_dict = {x: x**2 for x in range(10)}