When running this code each letter in the word inputed is supposed to be printed out one after another with a time gap inbetween them. For some reason the code prints the whole word at once after a time period. Can anybody help?
import time
def load_word(word, speed):
for letter in word:
print(letter, end = "")
time.sleep(speed)
load_word("hello world", 0.15)
CodePudding user response:
you need to flush the buffers like so
print(letter, end='', flush=True)
CodePudding user response:
Try this:
print(letter, end="", flush=True)