Here in this post, we’ll see what is generator expression and most important we will compare List Comprehension and Generator Expression to know the difference between them and which one we should use and why. Let’s take List comprehension and generator expression one by one. First, let’s recall what we know about list comprehension. If […]
Using List and Dictionary Comprehensions in Python
List Comprehensions and Dictionary Comprehensions in Python are the important expressions you must know. Using comprehensions in the code will help us in making our code short and precise. Comprehensions in Python can achieve the output with a single line of code. Let’s consider an example below where we used a for loop to multiply […]