I have a for loop that goes into a list that has 10 items. For every item it has it adds 10 more to the list with the for loop. I want to kill the loop once the list length is 100 is this possible or I can't get out of the loop because the list never ends growing?
This is my code:
keywords = [
"apple store",
"applesauce recipe",
"applesauce",
"appleseeds",
"apples to apples",
"apples and honey",
"applesauce cake",
"apple support",
"apples and bananas"
]
for i in keywords:
url = "http://suggestqueries.google.com/complete/search?output=firefox&q=" + i
response = requests.get(url, verify=False)
suggestions = json.loads(response.text)
for word in suggestions[1]:
k = word
keywords.append(k)
print(word)
I tried adding the following at the end but no luck
if len(keywords) == 100:
print('this is where it needs to break')
break
I see the print message when it hits 100, but it keeps going.
Any idea?