Snippet to output lines of characters with effect in python
Python, 13 lines
1 2 3 4 5 6 7 8 9 10 11 12 13
#!/usr/bin/python3 import sys import time string = input('Any string you want: ') s = 0 while s < len(string): sys.stdout.write(string[s]) sys.stdout.flush() time.sleep(0.06) # set the time milliseconds for faster output s = s + 1 sys.stdout.write('\n')
It could be written in a slightly more pythonic way:
If you want something more in line with the interactive novel style, you can also split your line around the full stops:
Cool man! Thanks for that!