Last active
February 17, 2021 07:03
-
-
Save Deniz97/b6aa87ba4fdd7e489d9485ed6b8e9ab8 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
| my_initial = "m" | |
| levels = int(input("number of levels:")) + 1 | |
| if(levels < 1 or levels >7): | |
| print("Bad number of levels, exiting") | |
| exit() | |
| names = [] | |
| for i in range(levels): | |
| n1 = input("level %s, name 1: " %i) | |
| if not n1.islower(): | |
| print("name should be all upper case, exiting") | |
| exit() | |
| n2 = input("level %s, name 2: " %i) | |
| if not n2.islower(): | |
| print("name should be all upper case, exiting") | |
| exit() | |
| names.append((n1[0], n2[0])) | |
| max_width = 2*(levels) - 1 | |
| # handle top | |
| print(" " * ((max_width // 2)+1), end = "") | |
| print(my_initial, end = "") | |
| print(" " * ((max_width // 2)+1)) | |
| # handle rest | |
| for i in range(levels): | |
| spaces = (max_width // 2) - i + 1 | |
| print(" " * (spaces - 1), end = "") | |
| print(names[i][0], end = "") | |
| print("_"* (i*2 + 1), end = "") | |
| print(names[i][1], end = "") | |
| print(" " * (spaces - 1)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment