import sys from time import sleep def animate(text): for letter in text: print(letter, end="") sys.stdout.flush() sleep(0.05) # I use 0.05 but you can change it animate("This will be animated")
Here is what the above code is Doing:
1. It’s printing each letter of the text one by one.
2. It’s flushing the output buffer after each letter.
3. It’s sleeping for 0.05 seconds after each letter.