One-Line Collections (Comprehensions) In JavaScript, we often use , , or to transform arrays. Python has a more compact feature called comprehensions , which let you create new lists, sets, or dictionaries in a single readable line. To make it easier to remember, think of them as one-line collections — a shortcut way to build or transform data. List Comprehensions JS equivalent with : With Condition JS equivalent with : Nested Loops in Comprehensions JS equivalent using flatMap: Set Comprehensions JS equivalent (manual since has no comprehension): Dictionary Comprehensions JS equivalent using : Example – Inventory Filter ✅ Why it matters : Comprehensions give you a cleaner, faster way to transform data compared to writing full loops. They combine the power of , , and into one expressive syntax — one of the most “Pythonic” ways to write code .