Printing 'B' alphabet in star pattern with Python




To print 'B' 

we will conclude that we have 5rows and 3 columns and we will put some conditions with the if statement.

For source code: Pattern source code on github



for row in range(5):
    for col in range(3):
       if((col==0 or col==2) or ((col==1) and (row!=1 and row!=3))):

        print("*",end="")
       else:
        print(end=" ")
    print()


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


123 =COLUMN
ROW=0***
ROW=1* *
ROW=2***
ROW=3* *
ROW=4***

We want space at row=1 and row=3 so we have given the condition with col=1

Comments

Popular Posts