4 ms·
or you could just be eager and use lists: >>> [[(i, j) for i in "abc"] for j in range(3)] [[('a', 0), ('b', 0), ('c', 0)], [('a', 1), ('b', 1), ('c', 1
by _ZeD_ 3y ago
or you could just be eager and use lists:
>>> [[(i, j) for i in "abc"] for j in range(3)]
[[('a', 0), ('b', 0), ('c', 0)], [('a', 1), ('b', 1), ('c', 1)], [('a', 2), ('b', 2), ('c', 2)]]
- nerdponx 3y agoRight, creating generators in a loop is not usually something you want to do, but it's meant to demonstrate the complexity that arises from late binding rather than demonstrate something you would actually want to do in a real program.