If you have a loop that has a number of iterations or takes a long time to run, you can get an easy progress bar (with an estimated time to completion) using tools like tqdm or Rich. They also work in Jupyter notebooks.
Change your loop from:
for i in range(10000):
...
to:
from tqdm import tqdm
for i in tqdm(range(10000)):
...
And get this for free:
76%|████████████████████████████ | 7568/10000 [00:33<00:10, 229.00it/s]
You can also manually update the progress bar in your code using tqdm.update()
.
Rich works in a similar way, and also provides rich console output more generally.