I'm trying to make a kind of simple progress bar, when each half a second the percentage is going up; The output is constantly updating itself. For this I tried to use the '\r' argument, but the code just ignores it and prints the progress bar over and over until it gets to 100 percent.
Here is the code:
import time
def progressBar(value, endvalue, bar_length=20):
    while value <= endvalue:
        percent = float(value) / endvalue
        arrow = '-' * int(round(percent * bar_length)-1) + '>'
        spaces = ' ' * (bar_length - len(arrow))
        print("\rPercent: [{0}] {1}%".format(arrow + spaces, int(round(percent * 100))))
        value+=1
        time.sleep(0.5)
progressBar(1, 100)
output:
Percent: [>                   ] 1%
Percent: [>                   ] 2%
Percent: [>                   ] 3%
Percent: [>                   ] 4%
Percent: [>                   ] 5%
Percent: [>                   ] 6%
Percent: [>                   ] 7%
Percent: [->                  ] 8%
Percent: [->                  ] 9%
Percent: [->                  ] 10%
Percent: [->                  ] 11%
And so on and on.
Can someone tell me what is the problem here?
 
     
    
 
     
    