How to Build a Progress Bar in Python

How to Build a Progress Bar in Python: A Step-by-Step Guide | Python Projects

When you are executing loops (really large ones), you can show a smart progress bar. A library called tqdm creates a progress meter that keeps track of the progress of your loop. To install the library run:

pip install tqdm

Lets say you have a range(100000) that you want your loop to run through, and after every loop, you want your code to sleep for 0.001 sec. Here is how you can implement it with tqdm so you can see the progress of the loop. When you run this code, you will get the progress meter below as the output.

from tqdm import tqdm
for i in tqdm(range(100000)):


17.02.2023 22.50.42 REC

You can also put a description in the function to make the progress meter more intuitive.

i   tqdm(range(100000), desc= ):


17.02.2023 22.51.55 REC

You can now see that the word "progress" in the progress meter. You can put in whatever description you want. Explore the module some more.


Spread the love

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top