Dec-30-2017, 12:47 PM
Hi everyone,
I am working on a program that decides if the content gets googled or if it searches for images. I filter the words and remove words that are not needed but there is a problem I can't figure out how to solve. If I input "search for pictures of Bitcoin" I get the output:
I will search for: pictures Bitcoin
I will search for pictures of: Bitcoin
Is it because of the for loop? I tried to remove words if they are in google so the loop will never be used but I didn't work:
Here is my code:
I am working on a program that decides if the content gets googled or if it searches for images. I filter the words and remove words that are not needed but there is a problem I can't figure out how to solve. If I input "search for pictures of Bitcoin" I get the output:
I will search for: pictures Bitcoin
I will search for pictures of: Bitcoin
Is it because of the for loop? I tried to remove words if they are in google so the loop will never be used but I didn't work:
Here is my code:
google_loop = 0 pictures_loop = 0 cut_words_google = ["for", "online", "of", "me"] cut_words_pictures = ["for", "online", "of", "me", "google", "search", "look", "online"] google = ["google", "search", "look", "online"] pictures = ["show", "images", "pictures", "photos"] words = input() test = words for word in words.split(" "): if word in pictures and word not in google: words = "" pictures_loop = 1 if word in google and word not in pictures: words = "" google_loop = 1 while google_loop == 1: for word in google: test = test.replace(word, "") for word in cut_words_google: test = test.replace(word, "") test = test.replace(" ", " ") print("I will search for: " + test) google_loop = 0 test == "" words == "" while pictures_loop == 1: for word in pictures: test = test.replace(word, "") for word in cut_words_pictures: test = test.replace(word, "") test = test.replace(" ", " ") print("I will search for pictures of: " + test) pictures_loop = 0 test == "" words == ""