I have a list with movie names: Movie List
And another list of questions about movies: List of questions
My objective is to loop through the list of questions and each time the function finds a name in the question that is in the list of movies, changes the name to "MOVIE". At the moment i can do it for each question: def remove_movie_name_1(text):
for i in tqdm(range(len(movies))):
return re.sub(movies[42], 'MOVIE', text)
remove_movie_name_1(tq[21])
This way i can change it for example from "What was the role played by Tim Allen in Toy Story 3?" to "What was the role played by Tim Allen in MOVIE?"
When i tried to apply it to the whole list I used this code:
def remove_movie_name(text):
for i in tqdm(range(len(movies))):
return re.sub(movies[i], 'MOVIE', text)
for i in tqdm(range(len(tq))):
tq[i] = remove_movie_name(tq[i])
But this code doesn't change anything and I can't see what's the problem. Thank you.