Math Range Error In Python Code