Skip to content
Advertisement

Tag: max

Remove NaN in a python list using max

In a recent interview I was given the following problem. We have a list l = [NaN, 5, -12, NaN, 9, 0] and we want to replaceNaN with -9 using the max function knowing that max(NaN, -9) = -9. What I have tried is : but the output is still the same list. Can’t figure out how to code this.

Advertisement