How to check for NaN values

math, nan, python

Solution

Use `math.isnan`:

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

Problem

`float('nan')` represents NaN (not a number). But how do I check for it?

Original source