Reputation: 115
string = """This is a
very long string,
containing commas,
that I split up
for readability"""
I want to output the above example, one line at a time, with a delay of say 0.5 seconds. I've found this question which does the same but prints characters with a delay.
Upvotes: 1
Views: 1361
Reputation: 369054
Split lines; iterate each line while printing it, then sleep after printing.
import time
string = """This is a
very long string,
containing commas,
that I split up
for readability"""
for line in string.splitlines():
print(line)
time.sleep(0.5)
Upvotes: 2