Skip to content

Instantly share code, notes, and snippets.

@Deniz97
Last active February 17, 2021 07:02
Show Gist options
  • Save Deniz97/f76bab50e870771948ec764528b4c575 to your computer and use it in GitHub Desktop.
Save Deniz97/f76bab50e870771948ec764528b4c575 to your computer and use it in GitHub Desktop.
my_initial = "D"
levels = int(input("number of levels:")) + 1
if(levels < 1 or levels >10):
print("Bad number of levels, exiting")
exit()
names = []
for i in range(levels):
n1 = input("level %s, name 1: " %i)
if not n1.isupper():
print("name should be all upper case, exiting")
exit()
n2 = input("level %s, name 2: " %i)
if not n2.isupper():
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