# Comprehensions in Python

---
title: "Comprehensions in Python"
seoTitle: "Python Comprehensions: List, Dict, Set, and Generator"
seoDescription: "A concise guide to list, dictionary, set, and generator comprehensions in Python with practical examples. Learn when comprehensions improve code..."
datePublished: Wed Dec 06 2023 22:18:07 GMT+0000 (Coordinated Universal Time)
cuid: clpubyrlh000008jn7u8cdbhd
slug: comprehensions-in-python
cover: https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/nVqNmnAWz3A/upload/810ea2a007ec5ba0b522c1d4e521bf48.jpeg
tags: programming-blogs, python, data-engineering, programming-tips

---

Do you work with Python comprehensions in your day-to-day?

Comprehensions are a straightforward way to create lists, sets, dictionaries and generators from existing iterables - such as lists or tuples.

They allow for short, concise notation as opposed to loops. As usual, it's important to think about code readability and not overuse them.

See below a quick worksheet with examples of common comprehensions in Python, applied in a simple scenario - computing number squares.

Thanks for reading!

![](https://miro.medium.com/v2/resize:fit:1400/0*0hj95ZOILj7fMVEJ align="left")

*Found it useful? Subscribe to my Analytics newsletter at* [*notjustsql.com*](https://www.notjustsql.com)*.*

---

*Enjoyed this? Here are some related articles you might find useful:*

- [Using SETS in Python](https://datawise.dev/using-sets-in-python)

