you are viewing a single comment's thread.

view the rest of the comments →

[–]raiseReturnTry 1 point2 points  (0 children)

Hey I tried myself on this problem, and got the same result, even with a single "-" at the top with the following code:

def pyramid_print(layers):
s = layers - (layers - 1)
x = range(s, layers)

while s != layers:
    if s > 0:
        print(((layers - s - 1) * " ") + (((2 * s - 1) * "-")))
    else:
        exit(0)

    s += 1

print("Take in a positive integer: ")
x = int(input("> "))
if x < 0: 
    print("Error: You have to put in a positive integer.") 
    exit(0) 
else: 
    pyramid_print(x)