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 library.

To install it, we run

pip install tqdm

Then we use it by writing

from time import sleep
from tqdm import tqdm

for i in tqdm(range(10)):
    sleep(3)

to call tqdm with range(10) to update the progress bar 10 times.

And we call sleep in the loop to pause for 3 seconds between each update.

Conclusion

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

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 *