Hi all, I’m doing the Guided Mission for Jeopardy. The following code is given in the solution:
def count_matches(row):
split_answer = row["clean_answer"].split(" ")
split_question = row["clean_question"].split(" ")
**if "the" in split_answer:**
** split_answer.remove("the")**
if len(split_answer) == 0:
return 0
match_count = 0
for item in split_answer:
if item in split_question:
match_count += 1
return match_count / len(split_answer)
jeopardy["answer_in_question"] = jeopardy.apply(count_matches, axis=1)
As far as I know, ‘remove’ only removes the first occurrence in the list. If the answer contains multiple times the word ‘the’, then only the first ‘the’ right? Shouldn’t we want to remove all ‘the’s’ in the answer?