I want to know if the list created (instantiated) and used in for loop will reduce efficiency of my program.
For example:
for i in range(1, 10000):
print("This i = ", i)
Please tell me if the list [1,2,3,...,10000] (which is range(1,10000)) will be generated (or instantiated) at every iteration or not. Because if Yes, then this is a huge overhead and inefficient program.
Actually I want to use it like this:
with open("bbc.txt", 'w', encoding='utf-8') as bbcFile:
for headline in BS(REQ.get("https://www.bbc.com").text, 'html.parser').find_all('div', {'class':'media__content'}):
bbcFile.write(" ".join(headline.text.split()) + "\n\n")