mardi 13 janvier 2015

python if clause with multiple conditions doesn't seems to work

Can someone explain to me why in the following code the message "Found an instance without object" is not printed along with the output?



filename= "S1-ADL1.dat"

with open(filename, 'r')as data:
for line in data:
valueList=line.split(' ')
print "valueList[247]"+valueList[247]
print "valueList[249]"+valueList[249]
if valueList[247] == '0' and valueList[249] == '0':
print "Found an instance without object"
continue
elif valueList[247]==0 and valueList[249]!=0:
valueList[247]=valueList[249]
valueList[246]=valueList[248]
print filename+' is written'


The output I get is as follows



valueList[247]0
valueList[249]0

valueList[247]0
valueList[249]0

valueList[247]0
valueList[249]0

S1-ADL1.dat is written


As you can see there are instances where the if statement is satisfied but it does not print the message in the if clause.


Aucun commentaire:

Enregistrer un commentaire