Explore Courses Blog Tutorials Interview Questions
0 votes
in Python by (47.6k 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

0 votes
by (106k points)

You can use math.isnan(x)to check for NaN values this will Return True if x is a NaN (not a number), and False otherwise.

>>> import math 

>>> x = float('nan') 

>>> math.isnan(x) 


Related questions

0 votes
1 answer
asked Oct 11, 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
asked Apr 5, 2020 in BI by Vaibhav Ameta (17.6k points)
+1 vote
1 answer
asked Jul 31, 2019 in Python by Aarav (11.4k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

30.5k questions

32.6k answers


108k users

Browse Categories