Is it possible to get multiple return values from inline for? e.g.,:
a,b=[(1,2) for _ in range(3)]
such that:
a=[1,1,1]
b=[2,2,2]
Is it possible to get multiple return values from inline for? e.g.,:
a,b=[(1,2) for _ in range(3)]
such that:
a=[1,1,1]
b=[2,2,2]
The zip
built-in can be kind of "abused" to yield this kind of output:
In [203]: a, b = zip(*((1,2) for _ in range(3)))
In [204]: a
Out[204]: (1, 1, 1)
In [205]: b
Out[205]: (2, 2, 2)