Last active
August 19, 2021 15:18
-
-
Save drazenz/8af60869b909bd2f4e7d19de05b4adca to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import string | |
| def print_center(text:str) -> None: | |
| term_len = 80 | |
| printable = ''.join([c for c in text if c in string.printable]) | |
| lines = printable.splitlines() | |
| if len(lines) > 1: | |
| for line in lines: print_center(line) | |
| elif len(printable) > term_len: | |
| print(printable[:term_len]) | |
| print_center(printable[term_len:]) | |
| else: | |
| print(printable.center(term_len)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment