I tested the following code with an online Python 3.x compiler but want a similar one to work on my 2.4.3 compiler:
import sys, time
print('I am about to show you something _\b', end='')
sys.stdout.flush() # Make sure above string gets printed in time
time.sleep(2)
print('THIS!')
How can I make a similar code work for Python 2.4.3?
Use the
printstatement with trailing comma to suppress the newline:Alternatively, write to
sys.stdoutdirectly:This works in Python 2 and 3 alike.