Problems with removal of newline printing

  python

I am having an unclear problem with something.

By default, Python’s print statement adds a new line.
To remove that, you add the end argument and set it to an empty string.

So I tried the following.
I used the time module and wrote the following code:

import time
quote = "Hiya there!"

print(quote[0], end="")

time.sleep(0.2)

print(quote[1], end="")

time.sleep(0.2)

print(quote[2], end="")

time.sleep(0.2)

print(quote[3], end="")

I expect this to print the first character, wait for 0.2 seconds, and print the next character (all in the same line). Then it waits for another 0.2 seconds and prints the next character. But instead, it waits for a total of 0.6 seconds and prints all four characters at the same time. Why is this happening, and is there a way to "fix" it?

Source: Python Questions

LEAVE A COMMENT