Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

algebraic pyramid python

def print_pyramid(pyramid):
    lines = []
    for layer in pyramid:
        line = ""
        for brick in layer:
            line += str(brick)
            line += " "
        lines.append(line)
    pyramid_len = max([len(layer) for layer in lines])
    txt = ""
    for line in lines:
        diff = (pyramid_len - len(line)) / 2
        txt += " " * int(diff + 0.5)
        txt += line
        txt += " " * int(diff - 0.5)
        txt += "
"
    print(txt)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #algebraic #pyramid #python
ADD COMMENT
Topic
Name
2+8 =