I have a simple for loop in a Python script:
for filename in filenames:
outline = getinfo(filename)
outfile.write(outline)
This for loop is part of a larger script that extracts data from HTML pages. I have nearly 6GB of HTML pages and want to do some test runs before I try it on all of them.
How can I make the loop break after a set number of iterations (lets say 100)?
for filename in filenames[:100]:
outline= getinfo(filename)
outfile.write(outline)
The list slice filenames[:100] will truncate the list of file names to just the first 100 elements.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With