convert negative to zero in list in python 1

convert negative to zero in list in python

[max(num, 0) for num in num_list]

Here is what the above code is Doing:
1. We create a list comprehension that iterates through num_list.
2. We use the max function to get the maximum value of num and 0.
3. We return the list of maximum values.

Similar Posts