SyntaxFix
Write A Post
Hire A Developer
Questions
Another minimalist Python solution without using numpy:
[0 if i < 0 else i for i in a]
No need to define any extra functions.
a = [1, 2, 3, -4, -5.23, 6] [0 if i < 0 else i for i in a]
yields:
[1, 2, 3, 0, 0, 6]