I've got the following piece of code:
def progressbar(count, total, status=""):
bar_len = 40
filled_len = int(round(bar_len * count / float(total)))
percents = round(100.1 * count / float(total), 1)
bar = "X" * filled_len + "-" * (bar_len - filled_len)
print("[{}] {}{} ...{}".format(bar, percents, "%", status),
end="\r", flush=True)
And for calling the progress bar:
total = 100
i = 0
while i < total:
i += 1
progressbar(i, total, status="Creating stuff")
time.sleep(1)
Where total is a number of iterations. When I run this code I get the progress bar running on multiple lines instead of just one. Any advice?