6 ms·
Of course, Python would have been way more awesome if they did not reject the much more reader-friendly and idiomatic: squared_div_by_3 = [ for i in ra
by pierrebai 3y ago
Of course, Python would have been way more awesome if they did not reject the much more reader-friendly and idiomatic:
squared_div_by_3 = [
for i in range(10):
if i % 3 == 0:
i**2
]
That is, just transforming the normal for loop and if into a list comprehension by surrounding it with brackets. It would even preserve the friendly forced blocking and indentation. Can you imagine?