I am using following code to display string with loop completition percentage:
for x in range(y,z):
completed = 100*(x-y)/(z-y)
sys.stdout.write(f'{completed:10.0f}% completed.'
sys.stdout.flush()
And I want all the strings to be displayed in the same line of windows cmd (earlier value removed, and new printed in same place)
Output I want to obtain, should look like this:
x% completed.
Where x value is updated with each iteration.
But the output i get looks like this:
0% completed. 1% completed. 2% completed. ...etc
From what i found it should work on other platforms than Windows, but I am interested about Windows solution.