4 ms·
Doesn't what you wrote work in a different, slower, way? I had in mind something analogous to r = [] for x in range(5): if 2>x: for y in
by omaranto 12y ago
Doesn't what you wrote work in a different, slower, way?
I had in mind something analogous to
r = []
for x in range(5):
if 2>x:
for y in range(5):
r.append((x,y))
I think what you wrote probably does:
r = []
for x in range(5):
for y in range(5):
if 2>x:
r.append((x,y))
The first loop completely skips looping over y if the condition on x fails, the second loop repeatedly tests x.
- Foxboron 12y agoHurm yes indeed. Interesting problem. I'll copypasta this and fix up an issue! Nice catch!