Categories
Python Answers

How to add a progress bar with Python?

Spread the love

Sometimes, we want to add a progress bar with Python.

In this article, we’ll look at how to add a progress bar with Python.

How to add a progress bar with Python?

To add a progress bar with Python, we can use the tqdm package.

To install it, we run:

pip install tqdm

Then we can use it by writing:

from time import sleep
from tqdm import tqdm
for i in tqdm(range(10)):
    sleep(3)

We call tqdm with the range(10) iterator to print out the progress 10 times.

Therefore, we should see the latest progress printed every 3 seconds.

Conclusion

To add a progress bar with Python, we can use the tqdm package.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

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