Added missing parentheses in: elif ((sbName.find("TE") > 1) and (sbName.find("TC") < 1)) or ((sbName.find("TE") < 1) and (sbName.find("TC") > 1)):