The usual (documented) way to do what you are describing (which only works with Python 3):
print('Iteration', i, 'Score:', uniform(0, 1), end='\r')
In Python 2, we need sys.stdout.flush() after printing, as shown in this:
print('Iteration', i, 'Score:', uniform(0, 1), end='\r') sys.stdout.flush()
Using an IPython laptop, I had to concatenate the string for it to work:
print('Iteration ' + str(i) + ', Score: ' + str(uniform(0, 1)), end='\r')
And finally, to make it work with Jupyter, I used this:
print('\r', 'Iteration', i, 'Score:', uniform(0, 1), end='')
Either you can split print before and after time.sleep if that makes sense, or you need to be more explicit:
print('Iteration', i, 'Score:', uniform(0, 1), end='') time.sleep(1) print('', end='\r')