Sure I know what list comprehension is, for reference i primarily use python myself, but you're just using a built-in function which could have been expressed in a more readable format as you've literally shown yourself
I've had a lot of classmates get very confused by a long comprehension where I've had to rewrite it as a normal for loop to explain it
The nly real advantages I can see from using comprehension is it's speed as I'm pretty sure it is compiled as a single line and that it is easier to pass to numpy
View all comments
Show parent comment
1
u/[deleted] May 30 '22
There's also syntactic sugar like list comprehensions, for example to get a list of all integers from 0 to 20 that are evenly divisible by 3:
Without list comprehensions that would be: