Hi! I am currently looking for some freelance projects. If you have a project idea in mind please feel free to send me an email or check out my personal website. If you want to get to know about my journey, you can read this article: How I got into programming

Comprehensions are a feature of Python which I would really miss if I
ever have to leave it. Comprehensions are constructs that allow
sequences to be built from other sequences. Three types of
comprehensions are supported in both Python 2 and Python 3:

list comprehensions

dictionary comprehensions

set comprehensions

We will discuss them one by one. Once you get the hang of using list
comprehensions then you can use any of them easily.

List comprehensions provide a short and concise way to create lists. It
consists of square brackets containing an expression followed by a
for clause, then zero or more for or if clauses. The
expressions can be anything, meaning you can put in all kinds of objects
in lists. The result would be a new list made after the evaluation of
the expression in context of the if and for clauses.

This can be really useful to make lists quickly. It is even preferred by
some instead of the filter function. List comprehensions really
shine when you want to supply a list to a method or function to make a
new list by appending to it in each iteration of the for loop. For
instance you would usually do something like this:

In the above example we are combining the values of keys which are same
but in different typecase. I personally do not use dict
comprehensions a lot. You can also quickly switch keys and values of a dictionary: