float('nan') results in Nan (not a number). But how do I check for it? Should be very easy, but I cannot find it.
float('nan')
math.isnan(x)
Return True if x is a NaN (not a number), and False otherwise.
True
False
>>> import math >>> x = float('nan') >>> math.isnan(x) True
2.1m questions
2.1m answers
60 comments
57.0k users