Section: Comprehensions and generators

Set comprehension

python
python
unique_lengths = {len(word) for word in words}

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Comprehensions and generators
List comprehension
List comprehension
OpenIn sheetpythonsame section
Filtered list comprehension
Filtered list comprehension
OpenIn sheetpythonsame section
Nested comprehension
Nested comprehension
OpenIn sheetpythonsame section
Generator expression
Generator expression
OpenIn sheetpythonsame section
Generator function with yield
Generator function with yield
OpenIn sheetpythonsame section
Define a function
Define a function