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.

How to frame two for loops in list comprehension python

I have two lists as below tags = [u'man', u'you', u'are', u'awesome'] entries = [[u'man', u'thats'],[ u'right',u'awesome']] I want to extract …

python list for-loop list-comprehension
Fastest way to convert an iterator to a list

Having an iterator object, is there something faster, better or more correct than a list comprehension to get a list …

python iterator list-comprehension
Are list-comprehensions and functional functions faster than "for loops"?

In terms of performance in Python, is a list-comprehension, or functions like map(), filter() and reduce() faster than a for …

python performance for-loop list-comprehension map-function
How to get the union of two lists using list comprehension?

Consider the following lists: a = ['Orange and Banana', 'Orange Banana'] b = ['Grapes', 'Orange Banana'] How to get the following result: …

python list-comprehension
How can I call a method on each element of a List?

Suppose that I have a list of cars : public class Car { private String brand; private String name; private String color; …

java list list-comprehension
Understanding nested list comprehension

I want to understand nested list comprehension. Below, I listed a list comprehension expression and their for loop equivalent. I …

python nested list-comprehension
Nested list comprehension with two lists

I understand how the simple list comprehension works eg.: [x*2 for x in range(5)] # returns [0,2,4,6,8] and also I understand how …

python nested list-comprehension
How can I compare a unicode type to a string in python?

I am trying to use a list comprehension that compares string objects, but one of the strings is utf-8, the …

python unicode python-2.7 list-comprehension
How to use re match objects in a list comprehension

I have a function to pick out lumps from a list of strings and return them as another list: def …

python regex list-comprehension
Forming Bigrams of words in list of sentences with Python

I have a list of sentences: text = ['cant railway station','citadel hotel',' police stn']. I need to form bigram …

python list list-comprehension nltk collocation