I'm using the Adafruit DHT11 Library for my temperature sensor. Sometimes the value that I get form that reading can't be converted to a float (I really don't know what kind of var type that is it only comes out every like 50 readings). Whenever this happens my script stops working with the error code: float() argument must be a string or a number. The piece of code where this would be important is:
mid = sum(list)/len(list)
print mid
humidity, temperature = Adafruit_DHT.read_retry(11,4)
temp = float(temperature)
if mid + 3 > temp > mid - 3:
del list[0]
print 'all safe %d' % (temp)
list.append(temp)
Isn't there some way to make an if expression where the temperature variable is tested before the conversion. The result if it isn't convertible would just be to skip the whole code and start at the beginning for a new reading.