Skip to content

Instantly share code, notes, and snippets.

@aasmpro
Created March 24, 2022 21:46
Show Gist options
  • Save aasmpro/e621ba058c4e2d3b61cf6661e873bfec to your computer and use it in GitHub Desktop.
Save aasmpro/e621ba058c4e2d3b61cf6661e873bfec to your computer and use it in GitHub Desktop.
Scrolling text, just like the ones you see in train stations :)
from time import sleep
def scrolling_text(text, screen_size, wait):
text = f"{' '*screen_size}{text}{' '*screen_size}"
while True:
for i in range(len(text) - screen_size):
print('\r', text[i:screen_size+i], end='', sep='', flush=True)
sleep(wait)
def main():
text = input("text = ")
screen_size = int(input("screen size = "))
wait = float(input("wait = "))
scrolling_text(text, screen_size, wait)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment