Full Pyramid || Special Character || Pattern || Python
In this we are going to see how to print the above pattern of pyramid/triangle of special character, using nested for loops in Python Programming Language.


print("\nEnter the number of rows\n", end='')
rows = int(input())
print("\n", end='')

for i in range(rows):

    for j in range(1, rows-i+1):
        print(" ", end='')
        j += 1

    # This loop is for the 1st half of the pyramid
    for k in range(0, i + 1):
        if i % 2 == 0:
            print("#", end='')
        else:
            print("#", end='')

    # This loop is for the 2nd half of the pyramid
    for l in range(i - 1, -1, -1):
        if i % 2 == 0:
            print("#", end='')
        else:
            print("#", end='')
    print("\n", end='')
    i += 1

# Coded by Sahil Shaikh

#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post