I am working with very large lists. I wish to replace elements satisfying a rule as quickly as possible.
For Example:
rule: if x < 0, replace with 0
Mylist: [1, 2, -4, -3, 4, -9]
Newlist: [1, 2, 0, 0, 4, 0]
I have Mylist and want to get Newlist. My best guess is to use enumerate, but not sure how to write this appropriately. Thanks
For Example:
rule: if x < 0, replace with 0
Mylist: [1, 2, -4, -3, 4, -9]
Newlist: [1, 2, 0, 0, 4, 0]
I have Mylist and want to get Newlist. My best guess is to use enumerate, but not sure how to write this appropriately. Thanks
Comment