Explore Courses Blog Tutorials Interview Questions
+1 vote
in Python by (11.4k points)
float('nan') results in Nan (not a number). But how do I check for it? Should be very easy, but I cannot find it

1 Answer

+2 votes
by (32.3k points)
edited by

Try to execute:


This will return True if x is a NaN (not a number), otherwise it will retutn False.

>>> import math

>>> x = float('nan')

>>> math.isnan(x)


To know more about this you can have a look at the following video:-

Related questions

0 votes
1 answer
asked Oct 14, 2019 in Python by Sammy (47.6k points)
+1 vote
1 answer
asked May 25, 2019 in Python by varsha (200 points)
0 votes
1 answer

Browse Categories