what are ways to append a variable and print it in place of the same line before it was?

You can do this by specifying the end argument in print() as '\r' or Carriage Return as it is known.

For instance:

for i in range(100):
    # Your check goes here
    print('[{}/100] have been checked.'.format(i), end='\r')

For the change to be noticeable you could use time.sleep() for a small interval like 0.5 secs. Something like this:

import time
for i in range(100):
    # Your check goes here
    print('[{}/100] have been checked.'.format(i), end='\r')
    time.sleep(0.5)

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top