samedi 21 novembre 2015

Python IF/ELIF statement

Okay so for some reason if statement works, but elif doesn't.. not sure why, there's been no syntax or indentation errors, script runs fine however it doesn't use elif as if it wasn't written..

example of code:

try:
    if '120' in resp.read():
        print '120'
        self.write_to_file('120' '\n')
        return True
    elif '130' in resp.read():
        print '130'
        self.write_to_file('130' '\n')
        return True
    else:
        print 'no number'
        return False
except:

Aucun commentaire:

Enregistrer un commentaire