[Python] Slow printing using time.sleep function

Discussão em 'Python' iniciado por Stack, Junho 21, 2025.

  1. Stack

    Stack Membro Participativo

    I want to print characters of a string slowly on the terminal on the same line using python3. i used this code.

    for i in "Hello":
    print(i,end='')
    time.sleep(0.2)


    this code waits for 0.2 * 5(len of "Hello") secs and prints all the characters at once.when i use sys.stdout.write() function instead of print function, it prints the characters line by line instead of same line. how do i print characters on same line with delay?

    Continue reading...

Compartilhe esta Página