Display a pyramid

  • prompt the user to enter number of line (1 – 15)
  • prints a number pyramid
number = eval(input("Enter the number of lines(only 1 - 15): "))

if (number >= 1) and (number <= 15):
    for i in range(number):
        nToPrint = i + 1
        spaces = number - nToPrint
        for j in range(spaces):
            print("   ",end="")

        n = nToPrint
        while n >= 1:
            print(format(n,"3d"),end="")
            n -= 1

        if(i+1) >= 2:
            for k in range(1,(i+1),1):
                print(format((k+1), "3d"), end="")



        print()

else:
    print("Number have to be 1 - 15")