If you put 'nan' in as a string, a cast to float will not raise an exception.
I am not sure this is a good design, but the counterintuitive workaround is this.
To test if a Python float is not a number, see if it is equal to itself!
....val = float(raw_input("Air speed of an unladen swallow: "))
if val != val
....print "foo also!"