python parallel list comprehension

Solutions on MaxInterview for python parallel list comprehension by the best coders in the world

showing results for - "python parallel list comprehension"
Mailys
01 Jan 2019
1# Use zip() to generate an single iterable from 2 lists:
2
3zip([1, 2, 3], ["a", "b", "c"]) >> [(1, "a"), (2, "b"), (3, "c")]
4
5example:
6
7xs = [some list]
8ys = [some other list]
9func(x,y): return some value
10
11[func(x, y) for x, y in zip(xs, ys)]
12
13will iterate over both lists simultaneously, running func() over
14each pair of values
15