Last active
December 16, 2020 13:36
-
-
Save ohiofi/c2c111e889212b3bd598cc959f3d47d8 to your computer and use it in GitHub Desktop.
A function that gives a typewriter effect to console text in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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