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.