W
Will Stuyvesant
Here is a question about list comprehensions [lc]. The
question is dumb because I can do without [lc]; but I am
posing the question because I am curious.
This:
.... result.append(w)['foo', 'bar', 'baz', 'my', 'your', 'holy', 'grail']
puts all the words in a list, like I want.
How to do this with [lc] instead of for-loops?
I tried funnies like [[w for w in L] for L in data],
that is correct syntax, but you'd never guess.
I know, silly! No need for [lc]! So there's my
question. I am sure a one-liner using [lc] will be very
enlightening. Like studying LISP.
question is dumb because I can do without [lc]; but I am
posing the question because I am curious.
This:
.... for w in d:data = [['foo','bar','baz'],['my','your'],['holy','grail']]
result = []
for d in data:
.... result.append(w)['foo', 'bar', 'baz', 'my', 'your', 'holy', 'grail']
puts all the words in a list, like I want.
How to do this with [lc] instead of for-loops?
I tried funnies like [[w for w in L] for L in data],
that is correct syntax, but you'd never guess.
I know, silly! No need for [lc]! So there's my
question. I am sure a one-liner using [lc] will be very
enlightening. Like studying LISP.