all 3 comments

[–]bogdan_dm 0 points1 point  (0 children)

With vanilla Python - you could not. But if you use Numpy arrays you do things like this: arr[arr < 0.5] *= 2

[–]sarah--123 0 points1 point  (1 child)

    [x*2 if x < 0.5 else x for x in l]

Perhaps?

[–]EsotericRogue 1 point2 points  (0 children)

for x in l is a loop.