When I want to print a string character by character, I always use
import sys
from time import sleep
string = 'This is a test'
for char in string:
sys.stdout.write(char)
sys.stdout.flush()
sleep(0.030)
This works incredibly well. But recently, I've tried adding a new way to implement it to my code and I'm not sure why it won't work. It seems like it would but instead of printing each character, it waits the sleep(0.030) multiplied by len(string) and prints it all at once.
from time import sleep
string = "This is a test"
for char in string:
print(char, end = '')
sleep(0.030)
What makes this different than the first?