for e,q_word in enumerate(q_li): if q_word.lower() == "how" and "how " + q_li[e+1] not in constants.ans_type: question_type="how" break if q_word.lower() == "how" and "how " + q_li[e+1] in constants.ans_type: question_type="hownum" break list1 = [] dateline_score = 0 if question_type=="who": for s in sent_list: score = Rules.whoRule(q,helper.remove_puncts(s)) list1.append((s,score)) elif question_type=="what": for s in sent_list: score = Rules.whatRule(q,helper.remove_puncts(s)) list1.append((s,score)) elif question_type=="when": dateline_score = Rules.datelineRule(q) for s in sent_list: score = Rules.whenRule(q,helper.remove_puncts(s)) list1.append((s,score)) elif question_type=="where": dateline_score = Rules.datelineRule(q) for s in sent_list: score = Rules.whereRule(q,helper.remove_puncts(s)) list1.append((s,score)) elif question_type=="hownum": for s in sent_list: score = Rules.howRule(q,helper.remove_puncts(s)) list1.append((s,score))