I have a simple loop which gets stuck on a division by zero error. I am running a bool to filter out zero-value denominators, but for some reason the bool I used isn't working. Can someone please help? I am using python 2.6.5
Here is a sample from my code:
for i in range(0,len(lines)):
line = lines[i]
line = line.split(";")
leansz = line[9]
FW = line[34]
FS = line[35]
print "FS: %s %s"%(FS,type(FS)) #troubleshooting the denominator and its type
if FS == "0": #I have tried FS == 0 and FS == "0" to no avail
print 'FS == "0"' #checking if bool is working
continue #return to top of loop if denominator is zero
LnSzRa = float(leansz)/(float(FS)/2) #division by zero error
Here is a sample of what is returned and then the error:
FS: 184
<type 'str'>
FS: 1241
<type 'str'>
FS: 2763
<type 'str'>
FS: 1073
<type 'str'>
FS: 971
<type 'str'>
FS: 0
<type 'str'>
Traceback (most recent call last):
File "mpreader.py", line 50, in <module>
LnSzRa = float(leansz)/(float(FS)/2)
ZeroDivisionError: float division