In Python, you can filter a list comprehension by adding an if statement to the end, e.g.:
[x for x in list if x<y]
I wish you could do the same in a for loop, e.g.:
for x in list if x<y:
@olligobber what if I want to do more than one thing? What if my loop is so enormous that storing the result of each step would cause problems?
@christianp Just def do(*args): return None, then [do(a := a + 1, a := a * 2, a := a * a) for _ in range(10)] works
The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!