I have some code that I want to return 'right' if the first two characters in the argument are CH
, DL
or PR
:
def validation_check(trans):
#Make sure the transaction is in proper format
r = re.compile('.. .. ......')
if r.match(trans) is None:
f = open("validation.errors.log", "a")
f.write(trans+'-Improper format' '\n')
f.close()
elif trans[0:1] != 'CH' or 'DL' or 'PR':
f = open("validation.errors.log", "a")
f.write(trans+ "-Invalid action" '\n')
f.close()
return "That is not a valid action!"
else:
return "right"
print (validation_check('CH SE NST231 072 00/01/23'))
But for some reason it keep executing the elif
statement. Why is this?