You can use manual control in tqdm by specifying a total argument in the constructor. Verbatim from the manual:

with tqdm(total=100) as pbar:
    for i in range(10):
        sleep(0.1)
        pbar.update(10)

UPDATE

To manually control the tqdm without the context manager (aka with statement), you will need to close the progress bar after you are done using it. Here is another example from the manual:

pbar = tqdm(total=100)
for i in range(10):
    sleep(0.1)
    pbar.update(10)
pbar.close()

For this to work you need to know the total number of expected runs. In your code it could look something like

...
pbar = tqdm(total = runs+1)
while currentData[0] <= runs:

    ### ROLLING THE DICES PROCESS ###
    dices = twinDiceRoll()
    currentData[1] += dices[2]  # Updating the current tile

    ### SURPASSING THE NUMBER OF TILES ONBOARD ###
    if currentData[1] > 37:   # If more than a table turn is achieved,
        currentData[0] += 1   # One more turn is registered
        currentData[1] -= 38  # Update the tile to one coresponding to a board tile.
        pbar.update(1)
    else:
        pass
...
pbar.close()

However, this code isn't perfect: consider if the currentData[1] is always less than 37 -- the progress bar will just stop and not update. If you try to update it in the else:... part, you might violate the total upper bound. This is a start tho :)

Answer from RafazZ on Stack Overflow
🌐
tqdm
tqdm.github.io β€Ί docs β€Ί tqdm
tqdm.tqdm - tqdm documentation
Manually update the progress bar, useful for streams such as reading files. E.g.: >>> t = tqdm(total=filesize) # Initialise >>> for current_buffer in stream: ...
🌐
GitHub
github.com β€Ί tqdm β€Ί tqdm
GitHub - tqdm/tqdm: :zap: A Fast, Extensible Progress Bar for Python and CLI Β· GitHub
$ seq 3 0.1 5 | tqdm --total 5 --update_to --null 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 5.0/5 [00:00<00:00, 9673.21it/s] $ seq 10 | tqdm --update --null # 1 + 2 + ...
Top answer
1 of 5
264

You can use manual control in tqdm by specifying a total argument in the constructor. Verbatim from the manual:

with tqdm(total=100) as pbar:
    for i in range(10):
        sleep(0.1)
        pbar.update(10)

UPDATE

To manually control the tqdm without the context manager (aka with statement), you will need to close the progress bar after you are done using it. Here is another example from the manual:

pbar = tqdm(total=100)
for i in range(10):
    sleep(0.1)
    pbar.update(10)
pbar.close()

For this to work you need to know the total number of expected runs. In your code it could look something like

...
pbar = tqdm(total = runs+1)
while currentData[0] <= runs:

    ### ROLLING THE DICES PROCESS ###
    dices = twinDiceRoll()
    currentData[1] += dices[2]  # Updating the current tile

    ### SURPASSING THE NUMBER OF TILES ONBOARD ###
    if currentData[1] > 37:   # If more than a table turn is achieved,
        currentData[0] += 1   # One more turn is registered
        currentData[1] -= 38  # Update the tile to one coresponding to a board tile.
        pbar.update(1)
    else:
        pass
...
pbar.close()

However, this code isn't perfect: consider if the currentData[1] is always less than 37 -- the progress bar will just stop and not update. If you try to update it in the else:... part, you might violate the total upper bound. This is a start tho :)

2 of 5
49

Because of the attention, this post is attracting I thought it would be good to point out how this can be achieved with an infinite while loop as well.

To use an infinite loop with tqdm you need to change your while loop into an infinite for loop by utilizing a generator.

Infinite loop (no progress bar)

while True:
  # Do stuff here

Infinite loop (with progress bar)

def generator():
  while True:
    yield

for _ in tqdm(generator()):
  # Do stuff here

The code above would create an indefinite progress bar that would look similar to this

16it [01:38,  6.18s/it]

Note that the generator could also be modified to work with a condition

def generator():
  while condition:
    yield
🌐
DataCamp
datacamp.com β€Ί tutorial β€Ί tqdm-python
Tqdm Python: A Guide With Practical Examples | DataCamp
September 12, 2024 - To manually update a tqdm progress bar, it’s important that the total parameter is specified as the estimate of maximum expected number of iterations. Then, as the code processes each new element, the progress bar needs to be updated using the update() method.
🌐
GitHub
github.com β€Ί tqdm β€Ί tqdm β€Ί issues β€Ί 1264
Update using current "total" (and not increment size) Β· Issue #1264 Β· tqdm/tqdm
October 20, 2021 - In my opinion, this is a common enough request and use-case that tqdm should provide it by default. Either call it .update_to(n) or change the existing method to .update(n, absolute=True).
🌐
Deepnote
deepnote.com β€Ί blog β€Ί ultimate-guide-to-tqdm-library-in-python
Ultimate guide to tqdm library in Python
Tqdm uses smart algorithms to minimize performance impact: it avoids excessive refresh by updating only after a minimum interval (0.1s by default) or a certain number of iterations.
🌐
tqdm
tqdm.github.io β€Ί releases
Release History - tqdm documentation
Added support for "restarting" a progressbar after a long pause without making the iteration rate go haywire. Simply call the unpause() method on the tqdm instance that is about to be restarted.
🌐
PyPI
pypi.org β€Ί project β€Ί tqdm
tqdm Β· PyPI
$ seq 3 0.1 5 | tqdm --total 5 --update_to --null 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 5.0/5 [00:00<00:00, 9673.21it/s] $ seq 10 | tqdm --update --null # 1 + 2 + ...
Find elsewhere
🌐
Analytics Vidhya
analyticsvidhya.com β€Ί home β€Ί overview of tqdm: python progress bar library (updated 2026)
Overview of TQDM: Python Progress Bar Library (Updated 2026)
December 26, 2025 - You simply import the library, wrap your iterable with the tqdm() function, and iterate over it. The progress bar will automatically update with each iteration, providing real-time feedback on the progress of your code.
🌐
tqdm
tqdm.github.io
tqdm documentation
Overhead is low -- about 60ns per iteration (80ns with tqdm_gui), and is unit tested against performance regression.
🌐
Medium
medium.com β€Ί @harshit4084 β€Ί track-your-loop-using-tqdm-7-ways-progress-bars-in-python-make-things-easier-fcbbb9233f24
Track your loop using tqdm: 7 ways progress bars in Python make things easier | by Harshit Gupta | Medium
September 25, 2021 - How to use tqdm if my loop increment with a different value every time? By creating pbar = tqdm(…) outside the loop and calling pbar.update(value) inside the loop.
🌐
SoByte
sobyte.net β€Ί post β€Ί 2021-11 β€Ί tqdm
tqdm:Python code progress display tool - SoByte
November 9, 2021 - The tqdm.update() method is used to manually update the progress bar and is useful for streaming operations such as reading files.
🌐
GitHub
github.com β€Ί tqdm β€Ί tqdm β€Ί releases
Releases Β· tqdm/tqdm
tqdm-bot released this Β· 11 Sep 08:35 Β· v4.70.1 Β· 9cf5a12 Β· This commit was created on GitHub.com and signed with GitHub’s verified signature. GPG key ID: B5690EEEBB952194 Β· Verified Β· Learn about vigilant mode. contrib.concurrent: fix no-len iterables (#1830 <- #1828) tests: major overhaul (#1819) update AI policy in PR template Β·
🌐
Panel
panel.holoviz.org β€Ί reference β€Ί indicators β€Ί Tqdm.html
Tqdm β€” Panel v1.9.4
The Tqdm indicator wraps the well known tqdm progress indicator and displays the progress towards some target.
🌐
Virtualitics
sdk.virtualitics.com β€Ί modules β€Ί virtualitics_sdk.utils.tqdm.html
tqdm - SDK v1.26.0
It is a tqdm wrapper that accept some parameters to update the front-end progress bar accordingly to the progress made in tqdm.
🌐
LinkedIn
linkedin.com β€Ί pulse β€Ί codereading-tqdm-updating-progress-amartya-chaudhuri
[CodeReading] Tqdm -- updating progress
From the GitHub page, usage is pretty straightforward. Just wrap the iterable object over tqdm to get a progress update.
🌐
crates.io
crates.io β€Ί crates β€Ί tqdm
tqdm - crates.io: Rust Package Registry
September 4, 2026 - Or add the following line to your Cargo.toml: tqdm = "0.8.1" docs.rs/tqdm/latest/tqdm Β· github.com/mrlazy1708/tqdm Β· Yiheng Du Β· Accessibility Β· Command line utilities Β· 879,513 Recent downloads Β· 3,490,737 Downloads all time Β· 19 Versions published Β·
🌐
Alexwlchan
alexwlchan.net β€Ί notes β€Ί 2025 β€Ί set-tqdm-total-later
You can set/update the total of a progress bar tqdm after it starts – alexwlchan
May 17, 2025 - import time import tqdm with tqdm.tqdm() as pbar: for _ in range(5): time.sleep(1) pbar.update(1) pbar.total = 5 pbar.refresh()
🌐
Medium
medium.com β€Ί @wepypixel β€Ί what-is-tqdm-in-python-installation-and-usage-guide-fb18658bf3f9
What is tqdm in Python? How to use and Effortless Installation | by Stilest | Medium
August 29, 2023 - In this code snippet, we use the tqdm function to wrap the file object, providing the total number of lines in the total parameter. tqdm then generates a progress bar that updates as each line is processed, giving you visibility into the progress ...