Answers for "python parallel list comprehension"

1

python parallel list comprehension

# Use zip() to generate an single iterable from 2 lists:

zip([1, 2, 3], ["a", "b", "c"]) >> [(1, "a"), (2, "b"), (3, "c")]

example:

xs = [some list]
ys = [some other list]
func(x,y): return some value

[func(x, y) for x, y in zip(xs, ys)]

will iterate over both lists simultaneously, running func() over
each pair of values
Posted by: Guest on July-14-2021

Code answers related to "python parallel list comprehension"

Python Answers by Framework

Browse Popular Code Answers by Language