I want to have a simple counter on a line that changes. I have the following:
from __future__ import print_function
from time import sleep
for i in range(400):
print("\r" + str(i), end = "")
sleep(0.5)
In Python 3, it works fine, with the counter incrementing on the same line, but in Python 2, nothing displays. How can I get it to display in Python 2?
EDIT: I am inclined towards solutions that work for both Python 2 and 3.