If you are working with large lists, you may need to have a sense of progress from time to time so that you do not just cluelessly stare at your screen.
This is where tqdm comes to help.
In a nutshell, it represents a package that can help you see a progress meter.
To start using it, we to install the package. You can install it just like any other Python library.
If you have pip as the package installer, you can just execute the following:
pip install tqdm
After we install it, we need to import it before we are able to call it:
from tqdm import tqdm
After that, we can use it with any iterable and not just lists.
Let’s say that we have an array of sentences and we want to loop through them:
sentences = [“First sentence.”, “Second sentence.”, “Third sentence.”]
All we have to do to use it is to put the iterable inside tqdm():
Here is the complete example:
Now, when you execute it, you can see a progress bar of the looping process.
That’s basically it. I hope you find it useful.