Skip to content

Instantly share code, notes, and snippets.

@ohiofi
Last active December 16, 2020 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ohiofi/c2c111e889212b3bd598cc959f3d47d8 to your computer and use it in GitHub Desktop.
Save ohiofi/c2c111e889212b3bd598cc959f3d47d8 to your computer and use it in GitHub Desktop.
A function that gives a typewriter effect to console text in Python
from time import sleep
import sys
def typewriter(str):
for letter in str:
sleep(0.01)
print(letter, end='')
sys.stdout.flush()
print("\n",end='')
list = [''' ██████╗ █████╗ ███╗ ███╗███████╗ ████████╗██╗████████╗██╗ ███████╗
██╔════╝ ██╔══██╗████╗ ████║██╔════╝ ╚══██╔══╝██║╚══██╔══╝██║ ██╔════╝
██║ ███╗███████║██╔████╔██║█████╗ ██║ ██║ ██║ ██║ █████╗
██║ ██║██╔══██║██║╚██╔╝██║██╔══╝ ██║ ██║ ██║ ██║ ██╔══╝
╚██████╔╝██║ ██║██║ ╚═╝ ██║███████╗ ██║ ██║ ██║ ███████╗███████╗
╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝''',
'''In the bird's nest is a large egg encrusted with precious jewels, apparently
scavenged by a childless songbird. The egg is covered with fine gold inlay,
and ornamented in lapis lazuli and mother-of-pearl. Unlike most eggs, this
one is hinged and closed with a delicate looking clasp. The egg appears
extremely fragile.''',
"good luck",
"fine work",
"I did it!",
"I've failed…",
"here!",
"not here!",
"I can't take this…",
"lonely…",
"don't you dare!",
"do it!",
"look carefully",
"listen carefully",
"think carefully"]
for eachStr in list:
typewriter(eachStr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment