Skip to main content


Python Pyramid with Input

In this code you can add any input numbers lets say... 7 and run


num=int(input())
sum=0

for i in range(1,num+1,1):
    for j in range(0,i,1):
        sum+=1
        print ('*',end=" ")
    print(" ")
max=num*(num+1)//2
for x in range(num,0,-1):
    for y in range(0,x,1):
        print('*',end=" ")
        max-=1
    print("")

so which you will get something like this.


*  
* *  
* * *  
* * * *  
* * * * *  
* * * * * *  
* * * * * * *  
* * * * * * * 
* * * * * * 
* * * * * 
* * * * 
* * * 
* * 
* 



🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍

Popular Posts

Python underline string, Python underline text, Underline python print

Python pip - Installing modules from IDLE (Pyton GUI) for python 3.7

Top 40 Python - String Processing in Python | Working with String in Python

Top 11 Essential Python Tips and Tricks

Python Program - When was I born? / Date of Birth / MY BIRTHDAY (using Python3+)





Subscribe to our Channel


Follow us on Facebook Page

Join our python facebook groups



Join us on Telegram