Back
float('nan') results Nan (not a number). It is very easy but how can I check?
float('nan')
You can use math.isnan() which will return True if the variable is a NAN else False
Syntax-math.isnan(variable)
Syntax-
math.isnan(variable)
Alternatively, another way to test for NaN is comparing the number to itself.
def isNaN(num): return num != num
def isNaN(num):
return num != num
30.9k questions
32.9k answers
500 comments
665 users