How can I check for the NaN value in Python?

How can I check for the NaN value in Python?

There is a special literal "nan" for the float type:

>>> num = float('nan')
>>> num
nan
>>> import math
>>> math.isnan(num)
True
>>>

Reference:

https://docs.python.org/3/library/stdtypes.html