Why float('Nan') == float('Nan') is False

ast none at gmail.com
Thu Feb 14 02:00:15 EST 2019


Le 13/02/2019 à 14:21, ast a écrit :
> Hello
> 
>  >>> float('Nan') == float('Nan')
> False
> 
> Why ?
> 
> Regards
> 

Thank you for answers.

If you wonder how I was trapped with it, here
is the failing program.


r = float('Nan')

while r==float('Nan'):
     inp = input("Enter a number\n")
     try:
	r = float(inp)
     except ValueError:
	r = float('Nan')



More information about the Python-list mailing list