0

If my code is as folllows:

from time import sleep
print('Hi')
sleep(1)
print('How are you?')

The output would be :

Hi
How are you?

How can I make it so that the output is Hi then after a second Hi changes into How are you in one line of the output and is not printed in another line?

1 Answers1

-1

Try this:

from time import sleep
print('Hi ', end='')
sleep(1)
print('How are you?')

You should get:

Hi How are you?
Zahin Zaman
  • 210
  • 3
  • 9
  • 1
    please do not replace existing answers on SO. It makes the site messy. https://stackoverflow.com/questions/5419389/how-to-overwrite-the-previous-print-to-stdout-in-python. You can flag the post as a duplicate. – Buddy Bob May 25 '21 at 05:14