Top "List-comprehension" questions

A syntactic construct which provides a concise way to create lists in a style similar to the mathematical set-builder notation.

Mapping a nested list with List Comprehension in Python?

I have the following code which I use to map a nested list in Python to produce a list with …

python list list-comprehension nested-lists map-function
Alternative to list comprehension if there will be only one result

I'm starting to get used to list comprehension in Python but I'm afraid I'm using it somewhat improperly. I've run …

python list-comprehension
List Comprehensions in Python to compute minimum and maximum values of a list

i have the following code to compute minimum and maximum values of a list in order to save memory efficiency …

python list max list-comprehension min
Is it Pythonic to use list comprehensions for just side effects?

Think about a function that I'm calling for its side effects, not return values (like printing to screen, updating GUI, …

python list-comprehension
How can I create the fibonacci series using a list comprehension?

I am new to python, and I was wondering if I could generate the fibonacci series using python's list comprehension …

python list-comprehension fibonacci
Filter out elements that occur less times than a minimum threshold

After trying to count the occurrences of an element in a list using the below code from collections import Counter …

python list-comprehension counter dictionary-comprehension
What is the advantage of a list comprehension over a for loop?

What is the advantage of using a list comprehension over a for loop in Python? Is it mainly to make …

python list-comprehension
Intermediate variable in a list comprehension for simultaneous filtering and transformation

I have a list of vectors (in Python) that I want to normalize, while at the same time removing the …

python list mapping filtering list-comprehension
Is the order of results coming from a list comprehension guaranteed?

When using a list comprehension, is the order of the new list guaranteed in any way? As a contrived example, …

python list-comprehension
Powerset of a set with list comprehension in Haskell

I am a complete beginner in Haskell and I have 11 exercises for homework, 10 of which I have already solved. I …

haskell recursion list-comprehension powerset