0

I have written a function that types out each letter of a string individually with an interval of 0.06 seconds between each letter.

import time
def Type(string):
    for i in string:
        print(i, end="")
        time.sleep(0.06)
    print("\n")
    time.sleep(0.8)

On my computer it works fine, but if I try it in VS Code on my new laptop it doesn't print them individually as it does on my PC, but rather goes through all the waiting intervals and then prints the string as a whole.

Help is much appreciated as I really can't figure it out

Cr3Ek
  • 1
  • 1
  • 2
    `print()` may uses buffer and sends text on screen when you send `\n`. So sometime you have to use `print(...., flush=True)` to inform buffer that you want to send it on screen. The same problem can be in other languages and/or in other functions which works with stream and use buffer. – furas Jul 21 '22 at 16:17
  • What is the result of your running on your PC? After I run your codes, it will print every character at intervals. – MingJie-MSFT Jul 22 '22 at 01:54

0 Answers0